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

**URL:** <https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680>\
**Category:** Help\
**Created:** [June 20, 2017, 6:04am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680 "2017-06-20T06:04:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 20, 2017, 6:04am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/1 "2017-06-20T06:04:47Z")

</div>

## 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](http://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](https://github.com/vallieres/jekyll-json-feed/pull/7).

## 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:

> \_entries  
> ├── images  
> ├── pages  
> └── posts  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── 2016  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── 01  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── 02  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── 03  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── 2017  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── 03  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── 04

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

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

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

Thank you for your help,  
Khayrattee

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [June 20, 2017, 3:55pm UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/2 "2017-06-20T15:55:06Z")

</div>

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.

> **[Permalinks](https://jekyllrb.com/docs/permalinks/)**
>
> Permalinks are the output path for your pages, posts, or collections. They allow you to structure the directories of your source code different from the directories in your output.

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 21, 2017, 5:59am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/3 "2017-06-21T05:59:46Z")

</div>

@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.

UPDATED:

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

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 21, 2017, 6:14am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/4 "2017-06-21T06:14:33Z")

</div>

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

UPDATED:  
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…

Cheers.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [June 21, 2017, 3:42pm UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/5 "2017-06-21T15:42:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 22, 2017, 4:37am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/6 "2017-06-22T04:37:52Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [June 22, 2017, 4:21pm UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/7 "2017-06-22T16:21:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 23, 2017, 2:03am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/8 "2017-06-23T02:03:52Z")

</div>

hi @rdyar, see below recap:

## What Is Working:

1. For Pages:

> **Pages**  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ this-is-a-sligified-title.md  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ another-title-page.md

1. For Posts:

> _posts  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|_\_\_\_ **2017-03-13** -a-post-slugified-title.md  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ **2017-06-06** -another-title.md

### Permalink for all:

permalink: **:slug/**

## What is NOT Working:

For pages:

> **\_posts**  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_ **pages**  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ this-is-a-sligified-title.md  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ another-title-page.md

For Posts:

> **\_posts**  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ a-post-slugified-title.md  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|\_\_\_\_ another-title.md

## Questions:

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

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [June 23, 2017, 4:20am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/9 "2017-06-23T04:20:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 23, 2017, 5:14am UTC](https://talk.jekyllrb.com/t/howto-question-structure-different-posts-types-think-gallery-posts-vs-article-post/680/10 "2017-06-23T05:14:49Z")

</div>

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.
