Set page status to hidden based on other page and site parameters

Hi, I am fairly new to Hugo, and would like to know if the following is possible.
We are using Hugo for product documentation, and sometimes the documentation page of a feature is already available, but I would like to exclude it from publishing.

The idea is to set a parameter on the page frontmatter (for example, available_from_version: 4.1), and to set the current version number in the config.toml of the site. Then during buildtime a partial template or similar could compare the two version numbers, and include the page in the build if the current_version_number is greater than or equal to the available_from_version parameter set in the page.
Is it possible to do that? So far I couldn’t get the page excluded from the sidebar menus and such.

(I would like to avoid manually setting the publishdate or draft status of these pages, as it is rather error-prone and easy to forget.)

Thanks for your help in advance!

I don’t know how to do what you want off the top of my head, but I disagree: setting a version number versus “draft: false” or omitting the draft front matter all together, seems about the same.

title: Example Docs
available_from_version: 4.1
draft: false


If you are using Hugo’s menu system, you can use your version number idea to conditionally load the menu items. :slight_smile:

Hi maiki,
Thanks a lot for the tip, I’ll look into the menu and see how we are using it.
The actual condition to decide when to include/exclude pages is a bit more complex, so I’d definitely want to avoid manually setting the draft parameter. But if it can’t be done from hugo, we’ll use a script instead :slight_smile: