Implementing feature flags

Hello everyone!

I’ve been doing a bit of research and I’m fairly new to Hugo, but was wondering if there was any system any of you have created that is similar to the functionality given by LaunchDarkly for feature flag toggle. LaunchDarkly is natively supported in Gatsby (which is another framework to possibly migrate to, although I find it quite a bit more complicated to get started in compared to Hugo), but isn’t something I’ve seen supported by Hugo.

I’ve been able to come up with a simple proof of concept by setting “flags” to be true/false in the config file and creating a shortcode that looks for the flag name in the config file and verifies whether it’s true or false, which will determine if that feature is visible on the front-end. However, we would need to implement it a bit further and check for internal/external access, making sure a Google crawl wouldn’t look at anything that’s a flag set to false, and also making sure that Algolia doesn’t see that content either that shouldn’t be publicly visible/accessible yet.

Thanks everyone!

Hey,

I don’t know what LaunchDarkly can do, but thinking out loud as to what you can do in Hugo:

  • Since adding new pages (which may be a new feature) in Hugo is (to put it simply) triggered by adding a new content file (e.g. a Markdown file)
  • Given that, I would put the feature flag config in this file
  • I would use the cascade keyword to apply these flags to the relevant pages (note that you can have a slice/array of cascade’s)
  • Re. hiding stuff, see Build Options | Hugo (also re Cascade)
  • The above may be too coarse grained, but you could easily adjust your robots.txt template + Algolia script to exclude any page with a feature flag set or something.