Self closing generator tag

Hi everyone,

I’ve just finished refreshing my website. One of the last steps was to make sure I’m generating valid HTML. I used the New HTML Checker.

The checker generates a warning for the Hugo generator meta tag. I add the tag to my pages like this:

{{ hugo.Generator }}

The meta tag added to the page looks like this:

<meta name="generator" content="Hugo 0.104.2" />

The tag generates a warning that states:

Self-closing tag syntax in text/html documents is widely discouraged; it’s unnecessary and interacts badly with other HTML features(e.g., unquoted attribute values). If you’re using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool.

Obviously I’m not about to stop using Hugo.

To make the warning go away the meta tag needs to look like this:

<meta name="generator" content="Hugo 0.104.2" >

My question is:

Is there any way to have the built in hugo.Generator function output a non self-closing tag?


Checked my site and found it right

<meta name=generator content="Hugo 0.104.2">

any post processing? Minifier?

That’s a good thought.

No, I’m not using any post processing or minifying.

I am using the ‘production’ environment variable to post process my CSS. I’ve just checked and the same tag is output regardless.

@techxplorer the built-in generator tag in Hugo is self-closing. I didn’t know that that was a “no no”.

You can insert this into your template:

 <meta name="generator" content="Hugo {{ hugo.Version }}">

Thanks @bep, that’s a neat solution.

The addition of the warning is a new one. See this discussion in the validator repository for context.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.