[HowTo Question] - Structure different Posts types - think gallery posts vs article post

Intro Me

Hello dear Jekyllrb Community.
It’s my first time here, so hello to everyone.
I’m currently in the process of revamping my wordpress-based blog (7php.com) into fully the jekyllrb way.
I have spent like 2 weeks now playing with jekyllrb, installing & hacking plugins, even contributing where I can, namely here.

My Question

I would like to gain a bit more control on how I work with posts & even pages.
My posts consist of:

  • normal blog posts
  • pages
  • image posts - An image with a title & a very short description

My concern is, all those “posts” scatter too much around in the same folder. Is there a way I can instruct Jekyllrb so that l “internally” categorise posts into the following hierarchy:

├── images
├── pages
└── posts
              ├── 2016
              │          ├── 01
              │          ├── 02
              │          └── 03
              └── 2017
                             ├── 03
                             └── 04

But I would also want Jekyllrb to still render all pages or even posts, under //domain.com/about-me-page.html

Is there any way I could achieve this kind of structuring within my jekyll workflow?

I do not have knowledge of Ruby - but I’m getting along OK so far.

Thank you for your help,

If I understand correctly you should be able to do that with permalinks without too much trouble.

Also, if I remember correctly, the directory structure can also be used to set the category - I believe the way you have it - (_posts at the top) the sub folders will be ignored. You can also do it the other way around and the folder above _posts becomes the category. So the way you have it the folder structure can just be for you to help organize them and will not effect the category. At least I think that is correct.

Then you just need to play with the permalink to get the url the way you want it.

Generally with jekyll there is no need to know ruby, I know zero ruby but get along well with jekyll. Understanding yaml and liquid is what you need.

@rdyar thanks for the reply.
The only issue is I am not using the date permalink.
My permalink is custom:

permalink: :slug/

So what do you suggest to achieve the hierarchy - this is just for my own internal convenience, not for the generated output.


Hey @rdyar surprisingly for me, this just seemed to be working out of the box. I have just to test it with the folder hierarchy I mentioned, and to my great surprise no configuration is needed, Jekyll loops through inner folders to find any Markdown file and it renders it, respecting the permalink!! FANTASTIC!!

I guess I should just have tried it, I’m thinking too much as a programmer, I need to take a step back. cheers

Hey @rdyar
unfortunately, I cannot achieve the same for pages, why is that? :frowning:

I found the “trick”. Even for pages it work, but it has to be named as YYYY-MM-DD-[slugify_title].md

Again, appreciate if you can help me find the logic/reasoning behind here to…


the date is not needed for pages - unless that is performing something magic somehow, or you want it. Dates are required on posts though.

ok, thanks for this info @rdyar

Is there any way I can stop the current default behaviour of finding the posts by as YYYY-MM-DD-[slugified_title].md and simply by as [slugified_title].md

you’ll have to recap what your problem is, and be more specific as to where the issues lies - posts, pages or collections.

I’m not sure what you mean by [slugified-title].md, are you just referring to the name you are giving files? my-file.html?

hi @rdyar, see below recap:

What Is Working:

  1. For Pages:

     |____ this-is-a-sligified-title.md
     |____ another-title-page.md

  1. For Posts:

___ 2017-03-13-a-post-slugified-title.md
      |____ 2017-06-06-another-title.md

Permalink for all:

permalink: :slug/

What is NOT Working:

For pages:

       |__ pages
                |____ this-is-a-sligified-title.md
                |____ another-title-page.md

For Posts:

      |____ a-post-slugified-title.md
      |____ another-title.md


  1. how to achieve the structure above for pages
  2. How to make posts work without prepending date in the slugified title.
  3. I would guess for posts since the permalink is not set to :pretty, I should have been able to name my posts simply as slugified-title.md

Hope that is much clear? Let me know if you need any additional info… thanks for everything

Posts have to have the date prepended, that is a requirement of anything in the _posts directory to actually work like a post.

pages are not posts, and should not be inside the _posts directory. I wouldn’t even put them in a _pages directory. Anything with an _ is either special (layouts, includes, sass, posts, collections) or is ignored I think.

I also think it is confusing to use a folder named _pages as a page is a thing in jekyll - basically a page is any web page on the site with front matter other than a post or a collection item, and there is no need for them to be in a special directory/folder.

All four examples above are correct - the top two are correct behavior, bottom ones not.

Ultimately there are only a few things special about posts - tags/categories being the main thing I can think of at the moment. If you don’t need the built in handling of those you can do a lot with just using either pages or collections and then you don’t have to use the date in the file name.

1 Like

Thank you very for the clear explanation @rdyar, it makes sense to me now.

About collections it’s not yet clear how it’s useful. I guess I need to read the jekyllrb docs another some more times.