[SOLVED] Permalink and nestedsections


#1

Hi, I’ve searched like crazy and can’t find a solution. I understand that Hugo’s URL design is oriented around content-type based root sections, but I want my site organized by topic. I wanted to use the following url mappings:

/content/CONTENTTYPE-1/TOPIC-1 -> DOMAIN/TOPIC-1/CONTENTTYPE-1
/content/CONTENTTYPE-1/TOPIC-2 -> DOMAIN/TOPIC-2/CONTENTTYPE-1

In other words, have a section based on one content type (blog, for example) but use subdirectories within that section to organize by topic. The key is to hide the content type section, however.

This does not seem possible. So, I thought would at least be able to nest a content type under a topic directory in content:

/content/TOPIC-1/CONTENTTYPE-1/ -> DOMAIN/TOPIC-1/CONTENTTYPE-1
/content/TOPIC-1/CONTENTTYPE-2/ -> DOMAIN/TOPIC-2/CONTENTTYPE-2

I then put an _index.md into the CONTENTTYPE-1 subdirectory, along with some items.md, which I thought made that subdirectory a ‘section.’ I had to explicitly set the content type in the frontmatter of the items in there, but once done, going to the URL works fine, it lists all the items in /content/TOPIC-1/CONTENTTYPE-2/ and uses the appropriate layout.

However, I want to use a custom URL for the item that includes the item’s title. But setting the Permalink for CONTENTTYPE-1 in config.tmol has no effect on the item’s URL suggesting that it is not a proper section.

I can, however, set the TOPIC-1 permalink to achieve a similar effect. This makes sense since TOPIC-1 is a section, but it seems you are unable to set permalink for nested sections, only root ones?


#2

Try “:sections” in your permalink config.