Skip to content
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

Posts in folders #371

Open
muuvmuuv opened this issue Apr 9, 2018 · 2 comments
Open

Posts in folders #371

muuvmuuv opened this issue Apr 9, 2018 · 2 comments

Comments

@muuvmuuv
Copy link

muuvmuuv commented Apr 9, 2018

I'm trying to create myself a web blog and want to include images to my blog posts, so I created a new folder into my _posts-folder and give it the same name as the .md file inside it. Then I put some images in my posts folder and linked them in the .md-file.
When I'm not trying to fetch the posts I get twice the posts I really have on my _posts-folder. Is it not possible to have posts-folder or did I something wrong?

folder structure:

  • source
    -- _posts
    --- sample
    ---- sample.md
    ---- image.jpg
@beryllium
Copy link
Member

When I set up my blog (whateverthing.com), I took this approach to posts:

source/
-- _posts/
---- YYYY-MM-DD-post-slug.md
-- img/
---- image1-for-post.jpg
---- image2-for-post.jpg

And then I used relative paths to point to them in regular html/markdown. When I wanted to reference something in the post template, rather than in the post itself, I used the front-matter for the post to store the image url:

---
title: post-slug
image: img/image1-for-post.jpg
---

And then in the HTML for the post template I could reference it like {% if page.image|default(false) %}<img src="{{page.image}}">{% endif %}.

This construct isn't the greatest for a large blog with many images, but nothing would stop me from adding subfolders inside the img/ folder.

The trouble with putting them inside the _posts folder is that the Sculpin formatting logic expects every file in there to be a post content type. It might be something that can be improved in the future, since it is definitely nice to be able to collect related information together, but as for right now the img/..../.....jpg approach would probably be the most flexible.

This is all stuff that would be very helpful to have in the documentation, so I am going to keep this issue open and tag it appropriately so that can be improved.

Thanks for bringing it up, and I hope this response is helpful.

@muuvmuuv
Copy link
Author

Thank you for the quick response @beryllium ! Unfortunately not, that is exactly how I do it right now… but I hope that this is going to be a feature in the future. It would be really useful because I use sculpin for my companies portfolio page right now (no need for a CMS).

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

No branches or pull requests

2 participants