head: improve the metadata exposed

* Improves the metadata exposed, such as site or post description, site
  or post image. Make use of <https://matuzo.at/blog/html-boilerplate>.
* Removes extra empty lines or identation due to badly written layout.
  However, minifying at build could be a good idea.
* Improves very slightly the webmanifest file.

Co-Authored-by: iGor milhit <igor@milhit.ch>
merge-requests/4/head
iGor milhit 2021-05-04 21:34:58 +02:00
parent 029a3ac174
commit e7de77b3ad
Signed by: igor
GPG Key ID: 692D97C3D0228A99
5 changed files with 81 additions and 59 deletions

View File

@ -1,11 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ .Language.Lang }}" prefix="og: http://ogp.me/ns#"> <html lang="{{ .Language.Lang }}" prefix="og: http://ogp.me/ns#">
{{- partial "head.html" . -}} {{ partial "head.html" . }}
<body> <body>
{{- partial "header.html" . -}} {{- partial "header.html" . -}}
<main class="container"> <main class="container">
{{- block "main" . }}{{- end }} {{- block "main" . }}{{- end }}
</main> </main>
{{- partial "footer.html" . -}} {{- partial "footer.html" . -}}
</body> </body>
</html> </html>

View File

@ -1,21 +1,21 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width">
<title>{{ .Title }} | {{ .Site.Title }}</title> <title>{{ .Title }} - {{ .Site.Title }}</title>
<link rel="canonical" href="{{ .Permalink }}"> <link rel="canonical" href="{{ .Permalink }}">
{{- partial "metadata.html" . -}} {{- if .Site.IsServer -}}
{{ if .Site.IsServer }} {{- $options := (dict "targetPath" "styles.css" "enableSourceMap" true) -}}
{{ $options := (dict "targetPath" "styles.css" "enableSourceMap" true) }} {{- $styles := resources.Get "scss/main.scss" | toCSS $options }}
{{ $styles := resources.Get "scss/main.scss" | toCSS $options }} <link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen"> {{- else -}}
{{ else }} {{- $options := (dict "targetPath" "styles.css") -}}
{{ $options := (dict "targetPath" "styles.css") }} {{- $styles := resources.Get "scss/main.scss" | toCSS $options | minify -}}
{{ $styles := resources.Get "scss/main.scss" | toCSS $options | minify }} <link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen"> {{- end }}
{{ range .AlternativeOutputFormats }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end }} {{ end }}
{{ range .AlternativeOutputFormats -}} {{ partial "metadata.html" . -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">

View File

@ -1,35 +1,57 @@
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"> <meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ else }}Personal portfolio{{ end }}">
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/"> <meta property="og:title" content="{{ .Title }} - {{ .Site.Title }}">
<meta property="og:site_name" content="{{ .Site.Title }}"> <meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:url" content="{{ .Permalink }}"> <meta property="og:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ else }}Personal portfolio{{ end }}">
<meta name="DC.creator" content="{{ .Site.Author.name }}"> {{ if .Params.postimage -}}
<meta name="DC.language" content="{{ .Language.Lang }}"> <meta property="og:image" content="{{ .Site.BaseURL }}images/{{ .Params.postimage }}">
{{ if .IsNode }} {{- else if .Site.Params.Image -}}
<meta name="DC.title" content="{{ .Site.Title }}"> <meta property="og:image" content="{{ .Site.BaseURL }}images/{{ .Site.Params.Image }}">
{{ end }} {{- else -}}
{{ if .IsPage }} <meta property="og:image" content="{{ .Site.BaseURL }}images/site.jpg">
{{ end }}
{{ if .Params.postimagedescription -}}
<meta property="og:image:alt" content="{{ .Params.postimagedescription }}">
{{- else if .Site.Params.ImageDescription -}}
<meta property="og:image:alt" content="{{ .Site.Params.ImageDescription }}">
{{- else -}}
<meta property="og:image:alt" content="Grayish sheep portrait">
{{ end }}
<meta property="og:locale" content="{{ .Language.Lang }}">
{{- if .IsNode }}
<meta property="og:type" content="website">
{{- else }}
<meta property="og:type" content="blogPost">
{{ end -}}
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:url" content="{{ .Permalink }}">
<link rel="canonical" href="{{ .Permalink }}">
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/">
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/">
<meta name="DC.creator" content="{{ .Site.Author.name }}">
<meta name="DC.language" content="{{ .Language.Lang }}">
{{- if .IsNode }}
<meta name="DC.title" content="{{ .Site.Title }}">
{{ end }}
{{- if .IsPage }}
<meta name="DC.type" content="blogPost"> <meta name="DC.type" content="blogPost">
<meta name="DC.title" content="{{ .Page.Title }}"> <meta name="DC.title" content="{{ .Page.Title }}">
<meta name="DC.created" <meta name="DC.created" content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}">
content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}"> <meta name="DC.date" content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}">
<meta name="DC.date" {{- if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }}
content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}"> <meta name="DC.modified" content="{{ .Lastmod }}">
{{ if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }} {{ end -}}
<meta name="DC.modified" content="{{ .Lastmod }}"> <meta name="og:article:published_time" content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}">
{{ end }} {{- if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }}
<meta name="og:article:published_time" <meta name="og.article:modified_time" content="{{ .Lastmod }}">
content="{{ dateFormat "2006-01-02" (default .Date (.PublishDate)) }}"> {{ end -}}
{{ if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }} {{- with .Params.categories }}
<meta name="og.article:modified_time" content="{{ .Lastmod }}"> {{- range . -}}
{{ end }} <meta name="DC.subject" content="{{ . }}">
{{ with .Params.categories }} {{- end -}}
{{ range . }} {{ end -}}
<meta name="DC.subject" content="{{ . }}"> {{- with .Params.tags }}
{{ end }} {{- range . -}}
{{ end }} <meta name="DC.subject" content="{{ . }}">
{{ with .Params.tags }} {{ end -}}
{{ range . }} {{ end -}}
<meta name="DC.subject" content="{{ . }}"> {{ end -}}
{{ end }}
{{ end }}
{{ end }}

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -1,6 +1,6 @@
{ {
"name": "", "name": "iGor milhit",
"short_name": "", "short_name": "iG",
"icons": [ "icons": [
{ {
"src": "/android-chrome-192x192.png", "src": "/android-chrome-192x192.png",