Turning off aliases in for particular versions

We currently have a issue where we want non-versioned aliases to go to the latest version of our documentation.

As a made-up example, if someone goes to widget.com/install.html, we want to redirect them to widget.com/version12/install.html, where version 12 is the current latest version.

So version12/install.md would contain the alias:

  • /install.html

However, this means that when we add a new version 13, by duplicating the version12 folder and calling the duplicate version13, we now have two copies of each aliases: one in the version12 folder, and one in the version13 folder.

And unfortunately by default, the alias will take you to the earlier version (version12, not version13).

We could simply clear all aliases from the version12 folder but we have a lot. This is also why we don’t want to have server redirects instead of Hugo aliases.

Is there a way to make the latest version the default for any aliases?

P.

Create a custom alias template.

1 Like