Using :sections in permalinks not working as expected

My goal is to have permalinks reflect only the top two levels of my content hierarchy (that is, “posts” and one more). I am using :sections in my permalinks configuration (as documented here).

I have tried, following the docs and also this issue comment, these variations in my config.json:

"permalinks": { "posts": "/:sections[:2]/:title/" },  // generates at /posts/title/
"permalinks": { "posts": "/:sections[1:2]/:title/" }, // generates at /title
"permalinks": { "posts": "/:sections[0:2]/:title/" }, // generates at /posts/title/
"permalinks": { "posts": "/:sections[0:3]/:title/" }, // generates at /posts/title/

The generated permalinks are shown for content in /posts/section-a/section-b/bundle-directory/

So – none of the given configurations seem to be able to capture section-a into the permalink as I would expect. Clearly I’m misunderstanding something about content hierarchies. Can you point me in the right direction?

Many thanks. (I am using hugo v0.92.1 extended.)

every section on every level needs a file.


Brilliant! Don’t know how I’d missed that – thanks so much!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.