Merge pull request #2926 from aplgr/fix/meta-description-order

Add configurable meta description fallback order
This commit is contained in:
Nuno C.
2026-05-13 23:07:44 +01:00
committed by GitHub
3 changed files with 16 additions and 2 deletions
+3
View File
@@ -42,6 +42,9 @@ fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384",
giteaDefaultServer = "https://git.fsfe.org"
forgejoDefaultServer = "https://v11.next.forgejo.org"
[seo]
# metaDescriptionOrder = ["summary", "description", "site"] # Controls the fallback order for the HTML meta description. Valid values are "summary", "description", and "site".
[header]
layout = "basic" # valid options: basic, fixed, fixed-fill, fixed-gradient, fixed-fill-blur
@@ -186,6 +186,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `showViews` | _Not set_ | Whether or not articles and list views are displayed. This requires firebase integrations to be enabled, look below. |
| `showLikes` | _Not set_ | Whether or not articles and list likes are displayed. This requires firebase integrations to be enabled, look below. |
| `robots` | _Not set_ | String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values. |
| `seo.metaDescriptionOrder` | `["summary", "description", "site"]` | Controls the fallback order for the HTML meta description. Valid values are `summary`, `description`, and `site`. Use `["description", "summary", "site"]` if you want front matter `description` to take precedence over `summary`. |
| `disableImageZoom` | `false` | Disables image zoom feature across all the images in the site. |
| `disableImageOptimization` | `false` | Disables image resize and optimization features across all the images in the site, except images using markdown syntax (`![](image.jpg)`) |
| `disableImageOptimizationMD` | `false` | Disables image resize and optimization features only for images using markdown syntax (`![](image.jpg)`). |
+12 -2
View File
@@ -17,8 +17,18 @@
{{ end }}
{{/* Metadata */}}
{{ with (.Params.Summary | default .Params.Description) | default .Site.Params.description }}
<meta name="description" content="{{ . }}">
{{ $metaDescriptionOrder := .Site.Params.seo.metaDescriptionOrder | default (slice "summary" "description" "site") }}
{{ $metaDescriptionSources := dict
"summary" .Params.Summary
"description" .Params.Description
"site" .Site.Params.description
}}
{{ $metaDescription := "" }}
{{ range $metaDescriptionOrder }}
{{ $metaDescription = $metaDescription | default (index $metaDescriptionSources (lower .)) }}
{{ end }}
{{ with $metaDescription }}
<meta name="description" content="{{ . | plainify }}">
{{ end }}
{{ with .Params.Tags | default .Site.Params.keywords }}
<meta name="keywords" content="{{ range . }}{{ . }},{{ end }}">