mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
schema: add schema support in meta data #844
This commit is contained in:
parent
9d01487e0d
commit
ebe1dd13fe
4 changed files with 61 additions and 3 deletions
|
@ -18,7 +18,7 @@ The Relearn theme is a fork of the great [Learn theme](https://github.com/matcor
|
|||
- Usable offline, no external dependencies
|
||||
- [Usable from your local file system via `file://` protocol](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#file-system)
|
||||
- Support for the [VSCode Front Matter extension](https://github.com/estruyf/vscode-front-matter) for on-premise CMS capabilities
|
||||
- [Support for Open Graph and Twitter Cards](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#social-media-meta-tags)
|
||||
- [Support for Open Graph, Schema and Twitter Cards](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#social-media-meta-tags)
|
||||
- **Configurable theming and visuals**
|
||||
- [Configurable brand images](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#change-the-logo)
|
||||
- [Automatic switch for light/dark variant depending on your OS settings](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#adjust-to-os-settings)
|
||||
|
|
|
@ -17,4 +17,5 @@
|
|||
{{- $authorName := partialCached "authorname.hugo" . }}
|
||||
<meta name="author" content="{{ $authorName }}">
|
||||
{{- partial "twitter_cards.html" . }}
|
||||
{{- partial "opengraph.html" . }}
|
||||
{{- partial "opengraph.html" . }}
|
||||
{{- partial "schema.html" . }}
|
57
layouts/partials/schema.html
Normal file
57
layouts/partials/schema.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
{{- /* based on Hugo 0.125.3 schema.html */}}
|
||||
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
|
||||
<meta itemprop="name" content="{{ . }}">
|
||||
{{- end }}
|
||||
|
||||
{{- with or .Description .Summary site.Params.Description }}
|
||||
<meta itemprop="description" content="{{ . }}">
|
||||
{{- end }}
|
||||
|
||||
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
|
||||
{{- with .PublishDate }}
|
||||
<meta itemprop="datePublished" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
|
||||
{{- end }}
|
||||
|
||||
{{- with .Lastmod }}
|
||||
<meta itemprop="dateModified" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
|
||||
{{- end }}
|
||||
|
||||
{{- with .WordCount }}
|
||||
<meta itemprop="wordCount" content="{{ . }}">
|
||||
{{- end }}
|
||||
|
||||
{{- $images := partial "_funcs/get-page-images" . }}
|
||||
{{- range first 6 $images }}
|
||||
<meta itemprop="image" content="{{ .Permalink }}">
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Keywords precedence:
|
||||
|
||||
1. Use "keywords" term page titles.
|
||||
2. Use "keywords" from front matter if "keywords" is not a taxonomy.
|
||||
3. Use "tags" term page titles.
|
||||
4. Use term page titles from all taxonomies.
|
||||
|
||||
*/}}
|
||||
{{- $keywords := slice }}
|
||||
{{- range .GetTerms "keywords" }}
|
||||
{{- $keywords = $keywords | append .Title }}
|
||||
{{- else }}
|
||||
{{- with .Keywords }}
|
||||
{{- $keywords = . }}
|
||||
{{- else }}
|
||||
{{- range .GetTerms "tags" }}
|
||||
{{- $keywords = $keywords | append .Title }}
|
||||
{{- else }}
|
||||
{{- range $taxonomy, $_ := site.Taxonomies }}
|
||||
{{- range $.GetTerms $taxonomy }}
|
||||
{{- $keywords = $keywords | append .Title }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $keywords }}
|
||||
<meta itemprop="keywords" content="{{ delimit . `,` }}">
|
||||
{{- end }}
|
|
@ -19,7 +19,7 @@ features = ["badges", "breadcrumbs", "boxes", "buttons",
|
|||
"oas", "offline usable", "openapi", "open graph",
|
||||
"print", "printable",
|
||||
"responsive", "rss", "rtl",
|
||||
"search", "search page", "sidebar", "sitemap", "subtheme", "swagger", "swaggerui", "syntax highlighting",
|
||||
"schema", "search", "search page", "sidebar", "sitemap", "subtheme", "swagger", "swaggerui", "syntax highlighting",
|
||||
"table of contents", "tab", "tabs", "tags", "taxonomy", "themeable", "themes", "toc", "topbar buttons", "twitter cards"]
|
||||
|
||||
[module]
|
||||
|
|
Loading…
Reference in a new issue