New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow posts and their media to be together in the filesystem #2266

Closed
spanezz opened this Issue Feb 26, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@spanezz
Copy link

spanezz commented Feb 26, 2016

Hello, and thank you for nikola.

I am trying to migrate from my current ikiwiki setup, and got stuck at the request of nikola that static content needs to go into a completely different directory hierarchy than the posts that use it.

In my case, I occasionally blog a post that contains just a picture with a few lines of text (like http://www.enricozini.org/2015/bremen/halmerweg/ ) and it feels very unwiedly to maintain image and markdown content into two entirely separate parts of the file system.

gohugoio/hugo#147 has more use cases and insight on this kind of request, from hugo-land where it has recently been implemented.

@ralsina

This comment has been minimized.

Copy link
Member

ralsina commented Feb 26, 2016

I think this already works, even if it needs a bit of configuration. Here is part of it, the rest is left as exercise for the reader:

IMAGE_FOLDERS = {'posts': 'posts'}
POSTS = (
    ("posts/*rst", "posts", "post.tmpl")
)

Then, just use the folder hierarchy inside posts for both your texts and your images, and put images and posts in the same places. If you have PRETTY_URLS enabled, you may need to use "../myimage.jpg" to link to images since posts are moved one level deeper.

@ralsina ralsina closed this Feb 26, 2016

@spanezz

This comment has been minimized.

Copy link

spanezz commented Feb 26, 2016

I confirm it works, though I feel like the need to use ../myimage.jpg to refer to an image in the same directory as the markdown content will lead me to confusion :/

@paternal

This comment has been minimized.

Copy link

paternal commented Feb 15, 2018

Late comment…

As @spanezz, I, too, come from Ikiwiki, and I, too, like to have my files next to my pages. I think I managed to achieve it:

  • in the conf.py, I set:

    FILES_FOLDERS = {
        'files': '',
        'pages': '',
        'posts': '',
    }
  • I do not use the images folder.

  • A page pages/foo.rst can have its files/images as pages/foo/image.jpg.

  • I can display image using:

    .. image:: image.jpg
  • I can link to files using:

    Download `my image <image.jpg>`__.

It is a very small website (for testing purpose), and I am new to nikola, so I have no idea whether this might have unintended bad consequences later…

-- Louis

@Kwpolska

This comment has been minimized.

Copy link
Member

Kwpolska commented Feb 15, 2018

@paternal Here’s a quick list of caveats I can think of:

  1. no auto-generated image thumbnails (done by the images folder)
  2. post/page sources (.rst) files are copied to output
  3. if pretty URLs are disabled (per post/everywhere), having COPY_SOURCES enabled (default) would create conflicts between the two attempts to create posts/foo.rst (pretty URLs means you get posts/foo.rst and posts/foo/index.rst)
@ralsina

This comment has been minimized.

Copy link
Member

ralsina commented Feb 15, 2018

@paternal there should be no bad consequences at all.

@spanezz what @paternal said should help you avoid the "../".

Another way is to put the post "foo" in posts/foo/index.rst and the images in posts/foo/whatever.jpg

@paternal

This comment has been minimized.

Copy link

paternal commented Feb 15, 2018

Thanks for the answers!☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment