What I want to achieve is to have all content to be rendered as HTML pages under
documentation directory in my project and have the resulting paths as follows:
├── documentation # root folder containing pages
│ ├── about.md # => http://example.com/about.html
│ ├── doc1.md # => http://example.com/doc1.html
│ ├── design # sub-folder containing pages
│ │ └── draft.md # => http://example.com/design/draft.html
│ // hunderds of pages and subfolders
Basically I want to eliminate the
documentation bit from the path:
http://example.com --/documentation-- /about.html
http://example.com --/documentation-- /design/draft.html
Jekyll manual hints that this might be achievable by using permalinks. I’ve experimented a bit with global configuration but couldn’t get the result I wanted. Specifically I had issues with preserving the subfolders in the path.
Is there a way to do that?
What you might want to consider doing is configure the documentation directory as a collection. Change it to
_documentation and do the needful in _config.yml so Jekyll outputs the files into .html and I’m pretty the default permalink settings will do what you want without needing to scope anything.
I’ve just tried that on a Jekyll generated project plus a handful of markdown files and it did not skip the collection name in the path. I suppose this behaviour makes sense as you could have a number of collections. Or have I misunderstood your suggestion?
This is the project:
│ └── design
│ ├── avatar.md
│ ├── codes.md
and the relevant bit of the config:
and this is the generated site:
│ └── design
│ ├── avatar.html
│ ├── codes.html
maybe try the permalink without the collection part in it. Not sure it will work but it might.
permalink: /:name #remove collection folder name?
This flattens the structure in both cases when I use a ‘collection’ or just a directory with ‘pages’:
bummer, I can see how the sub folder would be a problem. Not sure how to get around it short of doing a custom permalink on each file which does not sound feasible.