Permalink to subsections in config

Is it possible to configure permalinks for items in a section and subsections in the config?

I have content/pages/about.md and content/pages/policies/several-pages.md.

I want to access these at /about/ and /policies/some-page/ and /policies/some-other-page/.

In the config, under [permalinks], I have pages = "/:title/" which gives me /about/. If I change that to pages = /:section(s)/:title/, I end up with pages in the URL again. Also, use of :sections builds pages/some-page and not pages/policies/some-page as I would expect.

Is it possible to either exclude the section files directly under pages but include it for subsections or to do something like pages/about = "/about/" and pages/policies = /policies/:title?

No. Permalinks configuration is section wide. Using the forward slash like that in your config will throw an error and your site will not be generated at all.

But there are hacks circulating in the forum about configuring section URLs and excluding the section-name. Use the search button for those.

I believe that currently all pages in the section use the same permalink pattern.

I’d get the pattern you want working with sub-paths, and then override pages at the top-level in their front matter. So in /pages/about.md set url = "about".

1 Like

Yep, I found that out. Was wondering if there was an alternative solution. I’ll go take a look and see what else I can find as I hadn’t managed to find any hacks.

Note that

/:sections/:title/

Is a valid permalink pattern and will give you what you think it does. But that was probably not what was asked for. It is not possible to say /:sections[1]/:title/ or whatever.

I cannot seem to find these “hacks” please help. I am attempting the same thing as OP.

I made a post here: Second level nesting for permalink config