From bff5aa0b1ecb147b75bc06c1f3c5dcfc18f9fd2e Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Sun, 18 Apr 2021 10:50:02 +0200 Subject: [PATCH] added general meta tags for seo; added some article params to readme --- README.md | 9 +++++++++ layouts/partials/head.html | 7 ++++--- layouts/partials/head_meta_opengraph.html | 15 ++++++++++++--- layouts/partials/head_meta_seo.html | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/head_meta_seo.html diff --git a/README.md b/README.md index fde0b92..429fc89 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ summaryLength = 70 # number of words for article summaries [params] author = "Gabriele Musco" + description = "A description for my website" # this will be added as metadata + logo = "/images/mylogo.png" favicon = "/images/myfavicon.png" showTags = true # show the Tags menu item; default true @@ -166,6 +168,13 @@ Following is an example configuration: link: https://gitlab.gnome.org/gabmus ``` +## Params supported in a post frontmatter + +| Param | Description | +|-------|-------------| +| `tags` | An array of tags, useful for searching similar articles | +| `description` | A brief description of the post, useful for SEO optimization | +| `featured` | Boolean, indicate if the post should be shown as featured | ## Inject custom content diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 45271af..04e5450 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -4,9 +4,9 @@ if (location.host != new URL("{{ .Site.BaseURL }}").host) location.href = "{{ .Site.BaseURL }}" {{ end }} - - - + + + {{ if .OutputFormats.Get "RSS" }} {{ with .OutputFormats.Get "RSS" }} @@ -28,5 +28,6 @@ {{ $style := resources.Get "/scss/style.scss" | resources.ExecuteAsTemplate "/scss/style.scss" . | resources.ToCSS (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") | resources.Fingerprint "sha512" }} {{- partial "inject/head.html" . -}} + {{- partial "head_meta_seo.html" . -}} {{- partial "head_meta_opengraph.html" . -}} diff --git a/layouts/partials/head_meta_opengraph.html b/layouts/partials/head_meta_opengraph.html index b8bd1bb..06b0b79 100644 --- a/layouts/partials/head_meta_opengraph.html +++ b/layouts/partials/head_meta_opengraph.html @@ -9,18 +9,27 @@ - {{ range .Params.tags }} - + {{ if .Params.tags }} + {{ range .Params.tags }} + + {{ end }} {{ end }} - + {{ if .Params.description }} + + {{ else }} + + {{ end }} {{ else }} + {{ if .Site.Params.description }} + + {{ end }} diff --git a/layouts/partials/head_meta_seo.html b/layouts/partials/head_meta_seo.html new file mode 100644 index 0000000..3780fab --- /dev/null +++ b/layouts/partials/head_meta_seo.html @@ -0,0 +1,15 @@ + +{{ if .IsPage }} + {{ if .Params.tags }} + + {{ end }} + {{ if .Params.description }} + + {{ else }} + + {{ end }} +{{ else }} + {{ if .Site.Params.description }} + + {{ end }} +{{ end }}