I came across this old question while looking for a way to organize jekyll pages in a _pages
directory, similarly to _posts
. then access this pages without displaying the whole path in the url.
The approach that worked better for me, is to use jekyll collections as follows:
1 - Add a pages collection in _config.yml
:
collections:
pages:
output: true
permalink: /:path/
2 - create a new directory named _pages
(it should have the same collection name, prefixed by _
)
3 - add the pages in the _pages
folder, as .md or .html files starting with YAML Front Matter.
eg. /_pages/about.md
will looks like:
---
layout: page
---
<!-- about page content -->
after building that, the URL of the about page will be <your-web-site>/about
.
Alternatively, to display a collection name, you have to define its permalink as:
permalink: /:collection/:path/