Changing permalinks to a whole subsection

I’m working on a documentation page with a structure that looks like this:

content/
└── product1/
   ├── _index.md
   ├── 1.0/
   │   ├── _index.md
   │   ├── feature1.md
   │   ├── feature2.md
   │   └── featuren.md
   └── 1.1/
        ├── _index.md
        ├── feature1.md
        ├── feature2.md
        └── featuren.md

There are multiple products and versions. The default URLs (e.g. example.com/product1/1.0/feature1) are ok, but for the last version I would like to omit the version number.

I could achieve it by moving files or setting url in their Front Matter, but it’s not practical since we have hundreds docs per version. I would prefer to do it with a config if it’s possible.

I tried adding

permalinks:
  product/1.1: /product1/:slug/

but this doesn’t work.

You can’t do this with permalinks in site configuration, and as you pointed out, setting url in front matter is impractical.

So you’re left with modifying the structure of the content. Three options…

1) Change structure of the content directory.
2) Move older versions out of the content directory, then mount to content.

content/
├── product-1/
│   ├── feature-1.md
│   ├── feature-2.md
│   └── _index.md
└── _index.md
content-prior-versions/
└── product-1/
    ├── 1.0/
    │   ├── feature-1.md
    │   ├── feature-2.md
    │   └── _index.md
    └── 1.1/
        ├── feature-1.md
        ├── feature-2.md
        └── _index.md

site config

[[module.mounts]]
source = 'content'
target = 'content'

[[module.mounts]]
source = 'content-prior-versions'
target = 'content'

3) If the documentation for the prior versions is stable (zero or infrequent edits), do the same as #2 but stuff the older content in their own repositories, then mount them.

1 Like

Nice! That’s a great solution to my problem. Thanks! :slight_smile:

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