Don't use self-closing generator tag

This commit is contained in:
JB 2022-10-14 12:16:53 +02:00 committed by GitHub
parent a066e98851
commit 01ebb6e304
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View file

@ -68,7 +68,7 @@ func (i Info) Version() VersionString {
// Generator a Hugo meta generator HTML tag. // Generator a Hugo meta generator HTML tag.
func (i Info) Generator() template.HTML { func (i Info) Generator() template.HTML {
return template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, CurrentVersion.String())) return template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s">`, CurrentVersion.String()))
} }
func (i Info) IsProduction() bool { func (i Info) IsProduction() bool {

View file

@ -22,7 +22,7 @@ aliases: []
`hugo` returns an instance that contains the following functions: `hugo` returns an instance that contains the following functions:
hugo.Generator hugo.Generator
: `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.63.2" />` : `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.63.2">`
hugo.Version hugo.Version
: the current version of the Hugo binary you are using e.g. `0.63.2` : the current version of the Hugo binary you are using e.g. `0.63.2`

View file

@ -25,7 +25,7 @@ import (
var ( var (
metaTagsCheck = regexp.MustCompile(`(?i)<meta\s+name=['|"]?generator['|"]?`) metaTagsCheck = regexp.MustCompile(`(?i)<meta\s+name=['|"]?generator['|"]?`)
hugoGeneratorTag = fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, hugo.CurrentVersion) hugoGeneratorTag = fmt.Sprintf(`<meta name="generator" content="Hugo %s">`, hugo.CurrentVersion)
) )
// HugoGenerator injects a meta generator tag for Hugo if none present. // HugoGenerator injects a meta generator tag for Hugo if none present.

View file

@ -39,10 +39,10 @@ func TestHugoGeneratorInject(t *testing.T) {
META META
<foo /> <foo />
</HEAD>`}, </HEAD>`},
{`<head><meta name="generator" content="Jekyll" /></head>`, `<head><meta name="generator" content="Jekyll" /></head>`}, {`<head><meta name="generator" content="Jekyll"></head>`, `<head><meta name="generator" content="Jekyll"></head>`},
{`<head><meta name='generator' content='Jekyll' /></head>`, `<head><meta name='generator' content='Jekyll' /></head>`}, {`<head><meta name='generator' content='Jekyll'></head>`, `<head><meta name='generator' content='Jekyll'></head>`},
{`<head><meta name=generator content=Jekyll /></head>`, `<head><meta name=generator content=Jekyll /></head>`}, {`<head><meta name=generator content=Jekyll></head>`, `<head><meta name=generator content=Jekyll></head>`},
{`<head><META NAME="GENERATOR" content="Jekyll" /></head>`, `<head><META NAME="GENERATOR" content="Jekyll" /></head>`}, {`<head><META NAME="GENERATOR" content="Jekyll"></head>`, `<head><META NAME="GENERATOR" content="Jekyll"></head>`},
{"", ""}, {"", ""},
{"</head>", "</head>"}, {"</head>", "</head>"},
{"<head>", "<head>\n\tMETA"}, {"<head>", "<head>\n\tMETA"},