diff options
author | Greg Anders <greg@gpanders.com> | 2020-03-05 17:32:15 +0300 |
---|---|---|
committer | Greg Anders <greg@gpanders.com> | 2020-03-05 17:32:15 +0300 |
commit | b1d8f1ac770800352657c80eb9da90ccb7ca2101 (patch) | |
tree | 74474590102828758259a44eecc6f2f09cf2687d | |
parent | 905522e8747119f415032386800c8d6687762d01 (diff) |
Include <head> data in a separate partial
This allows theme users to easily customize what they want to include in
the <head> of their documents.
-rw-r--r-- | layouts/_default/baseof.html | 15 | ||||
-rw-r--r-- | layouts/partials/head.html | 14 |
2 files changed, 15 insertions, 14 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 8c412ea..c959174 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,20 +1,7 @@ <!DOCTYPE html> <html lang="{{ site.LanguageCode }}"> <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - {{ hugo.Generator }} - {{ if site.Params.schema }}{{ template "_internal/schema.html" . }}{{ end }} - {{ if site.Params.opengraph }}{{ template "_internal/opengraph.html" . }}{{ end }} - {{ if site.Params.twittercards }}{{ template "_internal/twitter_cards.html" . }}{{ end }} - <title> - {{ if eq .Title site.Title }} - {{ site.Title }} - {{ else }} - {{ with .Title }}{{ . }} | {{ end }}{{ site.Title }} - {{ end }} - </title> - <link rel="canonical" href="{{ .Permalink }}"> + {{ partial "head.html" . }} {{ range .AlternativeOutputFormats }} {{ printf "<link rel=%q type=%q href=%q title=%q>" .Rel .MediaType .Permalink site.Title | safeHTML }} {{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..24b71a7 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,14 @@ +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +{{ hugo.Generator }} +{{ if site.Params.schema }}{{ template "_internal/schema.html" . }}{{ end }} +{{ if site.Params.opengraph }}{{ template "_internal/opengraph.html" . }}{{ end }} +{{ if site.Params.twittercards }}{{ template "_internal/twitter_cards.html" . }}{{ end }} +<title> + {{ if eq .Title site.Title }} + {{ site.Title }} + {{ else }} + {{ with .Title }}{{ . }} | {{ end }}{{ site.Title }} + {{ end }} +</title> +<link rel="canonical" href="{{ .Permalink }}"> |