Template variables to pull Hugo version information

I think that it would be nice to have Hugo set up variables with the current version and “official” site information.

The use case is a meta-tag to display the version that created a site, plus give props on the web:

  <meta name="generator" content="Hugo 0.12 (http://gohugo.io)">

If Hugo had variables for the version and the URL, I could put this into my template:

  <meta name="generator" content="Hugo {{Hugo.version}} ({{Hugo.url}})">

Of course I can create those two variables myself and update them every time that I update Hugo, but would be nice to have Hugo set that up for me, especially so that I could just dump the line into my layout and never have to worry about it again.

At a minimum, this means having Hugo set the version and url variables. I don’t know what the impact would be to have Hugo generate the entire meta line. It seems harmless to me, but I can’t claim to be that familiar with the domain.

  {{Hugo.meta_generator}}
2 Likes

That’s a great idea. It’s not like showing that data is exposing security vulnerabilities like WordPress. :slight_smile: It would also allow for some web analysis of Hugo’s growing popularity. We could register it with companies like BuiltWith and Datanyze.

My vote is to have something along the lines of {{ Hugo.meta_generator }} so that it is consistent across the board. I also think it should be opt-out rather than opt-in.

I just submitted a PR to add a .Hugo variable and a new shortcode {{% hugo-generator %}}

2 Likes