How to change the root folder for pages?

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
│   ├──        # =>
│   ├──         # =>
│   ├── design          # sub-folder containing pages
│   │     └──  # =>
│   // hunderds of pages and subfolders
├── _config.yaml

Basically I want to eliminate the documentation bit from the path:

  • --/documentation-- /about.html
  • --/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.

      path: "documentation"
      permalink: ???

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.

1 Like

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:

├── 404.html
├── about.markdown
├── _config.yml
├── _documentation
│   └── design
│       ├──
│       ├──

and the relevant bit of the config:

    output: true

and this is the generated site:

├── 404.html
├── documentation
│   └── design
│       ├── avatar.html
│       ├── codes.html

maybe try the permalink without the collection part in it. Not sure it will work but it might.

    output: true
    permalink: /:name #remove collection folder name?
1 Like

This flattens the structure in both cases when I use a ‘collection’ or just a directory with ‘pages’:

├── 404.html
├── avatar.html
├── codes.html

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.