On Wed, Apr 22, 2015 at 5:10 PM, Mariano Draghi <
mdr...@gmail.com> wrote:
> Hi,
>
> TL;DR: I have several posts with embedded images, and I can't decide where
> to put the image files (FILES_FOLDER vs IMAGE_FOLDER vs GALLERY_FOLDERS),
> and whether I should use relative or absolute paths when linking from reST.
>
> [snip]
>
> And I'm really struggling to decide which is the best way to embed single,
> local images, in a post.
>
> For now I copied over the contents of my former "imgs" folder from WordPress
> inside the "images" folder in nikola. But I don't like that the images ended
> up in the root folder, with the posts. I suspect that's because IMAGE_FOLDER
> by default is {'images': ''}. Should I go for something like {'images':
> 'images'} instead?
Yes. I believe we could change the default config to this. Doing
that for the next version (for new sites only!).
https://github.com/getnikola/nikola/pull/1663
> Then, when I reference the file in reST, I can use an absolute path, like
> '/foobar.jpg', or a relative one, like '../foobar.jpg'. I know both work,
> but which is better in the long run?
Using an absolute path will be safer and easier. Nikola will actually
convert it to a relative path* and figure things out intelligently
(for example, it will point to a resource under your site even if you
are not deploying to the web server root). Writing a relative path
yourself can break things if your output structure changes (Nikola
won’t ever do it, you could if you get bored with the defaults or want
to reproduce WP-style /year/month/day/ if you haven’t already**).
Besides, why bother counting dots?
> Apart from the thumbnail generation, is there any other difference between
> having the images on a FILES_FOLDER or an IMAGE_FOLDER? If I want to just
> link an image, and I don't want a thumbnail, FILES_FOLDER seems a better
> choice. I'm leaning slightly towards the "files" folder... but as Nikola has
> specific folders/features dealing with images, I'm not 100% sure.
In this case, it does not matter which one you use. Using /files/
would only save you a few (mega)bytes of disk space and a few CPU
cycles because thumbnails won’t be generated.
> I've been looking around in GitHub for examples of what others are doing,
> and I've found that some people throw their imgaes in the gallery folder,
> and then link from there. It doesn't make much sense doing that for single
> images (i.e., if there is just one image on the post, or there are several
> unrelated ones). Am I missing something? Doesn't nikola treat the
> GALLERY_FOLDERS contents different?
Image folders were added only recently, these examples might be too
old to reflect that — and we didn’t do much marketing for the feature.
Files in /galleries/ can be freely browsed by anyone in a nice gallery
interface (duh!), /images/ are not but still have thumbnails, /files/
are just simply copied without any processing at all.
> You might say "Nikola is flexible, do what's best for you". But I can make
> it work with any of the alternatives, and I can't find the clear winner. I
> suppose I'm looking for some consensus, and for some insight on the intended
> use case for each of these features/alternatives to help me make up my mind
> :)
>
> Thanks for your advice and ideas!
I would just use /images/ in this case. You may want to use
thumbnails one day, and it will just look cleaner in your structure.
* with URL_TYPE = 'rel_path' (default config)
** cool URLs don’t change, it’s nice if you keep the same URL
structure. changing PRETTY_URLS and POSTS in config + manually
creating the year/month/day directories under posts will do it.
--
Chris Warrick <
https://chriswarrick.com/>
PGP: 5EAAEA16