Versioning of pages

Hey guys,

I’m building a documentation system which can show different versions of a page. For instance an API page that is different for every version (0.9.0, 0.9.1). The version can be chosen using a dropdown menu. I decided to create the folder structure like this:

There are a few problems using this method:

  • How can I detect what the biggest version is. I would assume using the filesystem and looking at the biggest number. But how do I do that within Hugo?

  • How to build the menu. Because every version would create it’s own sub-menu. I just want one menuitem per page. Could I just make a global version setting and parse the url with it?

I’m also open to whole other implementations if somebody got a better method of doing this.

1 Like

On my phone right now, but here are a few ideas or things to look at:

  1. Check out int in terms of ranging through pages and using comparators.
  2. It might be a bit of a hack, but you could assign API versions to weight, since this will let you sort individual markdown files numerically, although I’m not sure that’s the type of sorting you’re looking for.
  3. Create “versions” as version = "versions", a taxonomy in your config. You can range through taxonomies as well, which might help your drop down idea. You can also assign weights to taxonomies.

I think that is a great solution for ordering the items but what I want is to keep the folder structure but not show the last step in the menu. So only one item for all versions.

@brn I am currently making a documentation site and solving a similar problem.

Here is my post. How are you managing differently versioned pages?