Add microdata
This commit is contained in:
14
README.md
14
README.md
@@ -340,6 +340,17 @@ disable_toc = false
|
||||
# url = "https://example.com"
|
||||
base_schema = {}
|
||||
|
||||
# paige.page.microdata specifies the SEO microdata non-property attributes (all except itemprop) for the web page.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# [paige.page.microdata]
|
||||
# itemid = "123"
|
||||
# itemref = "foo"
|
||||
# itemscope = ""
|
||||
# itemtype = "https://schema.org/Chapter
|
||||
microdata = {}
|
||||
|
||||
# paige.page.schemas is the page JSON-LD schemas.
|
||||
#
|
||||
# Examples:
|
||||
@@ -453,6 +464,9 @@ or for pages with `paige.pages.schemas`, at the site or page level.
|
||||
A base schema can be specified for site schemas with `paige.site.base_schema`,
|
||||
and for page schemas with `paige.page.base_schema`.
|
||||
|
||||
HTML microdata is generated from the page parameters
|
||||
if the non-property attributes are specified in `paige.page.microdata`.
|
||||
|
||||
## Layouts
|
||||
|
||||
### Cloud
|
||||
|
@@ -1,5 +1,14 @@
|
||||
{{ $page := . }}
|
||||
|
||||
{{ $itemattrs := slice }}
|
||||
{{ $microdata := $page.Params.paige.page.microdata }}
|
||||
|
||||
{{ range $k, $v := $microdata }}
|
||||
{{ $itemattrs = $itemattrs | append (printf `%s="%v"` $k $v) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $itemattrs = delimit (sort $itemattrs) " " }}
|
||||
|
||||
<!doctype html>
|
||||
{{ partial "paige/tag-html.html" $page }}
|
||||
{{ partial "paige/tag-head.html" $page }}
|
||||
@@ -10,7 +19,7 @@
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col mt-3" id="paige-site">
|
||||
<div class="col mt-3" id="paige-site" {{ with $itemattrs }} {{ $itemattrs | safeHTMLAttr }} {{ end }}>
|
||||
{{ if templates.Exists "partials/paige/site-first.html" }}
|
||||
{{ partial "paige/site-first.html" $page }}
|
||||
{{ end }}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
{{ $first := templates.Exists "partials/paige/page-header-first.html" }}
|
||||
{{ $last := templates.Exists "partials/paige/page-header-last.html" }}
|
||||
{{ $link := $page.Params.link }}
|
||||
{{ $microdata := $page.Params.paige.page.microdata }}
|
||||
{{ $readingtime := $page.ReadingTime | and ($page.Param "paige.page.disable_reading_time" | not) }}
|
||||
{{ $series := $page.GetTerms "series" | and ($page.Param "paige.page.disable_series" | not) }}
|
||||
{{ $tags := $page.GetTerms "tags" }}
|
||||
@@ -26,11 +27,11 @@
|
||||
{{ end }}
|
||||
|
||||
{{ with $title }}
|
||||
<h1 class="fw-bold" id="paige-page-title">{{ if $link }}<a href="{{ $link }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}</h1>
|
||||
<h1 class="fw-bold" id="paige-page-title" {{ if $microdata }} itemprop="headline name" {{ end }}>{{ if $link }}<a href="{{ $link }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}</h1>
|
||||
{{ end }}
|
||||
|
||||
{{ with $description }}
|
||||
<p class="lead paige-row-wide" id="paige-page-description">{{ . }}</p>
|
||||
<p class="lead paige-row-wide" id="paige-page-description" {{ if $microdata }} itemprop="alternativeHeadline description" {{ end }}>{{ . }}</p>
|
||||
{{ end }}
|
||||
|
||||
{{ if or $authors $date $keywords $readingtime $series }}
|
||||
@@ -49,11 +50,11 @@
|
||||
{{- if $textkeywords -}}
|
||||
{{- if gt $i 0 }} · {{ end -}}
|
||||
|
||||
<a class="link-secondary paige-keyword paige-keyword-{{ $kind }}" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a>
|
||||
<a class="link-secondary paige-keyword paige-keyword-{{ $kind }}" href="{{ .RelPermalink | safeURL }}" {{ if $microdata }} itemprop="keywords" {{ end }}>{{ .Title }}</a>
|
||||
{{- else -}}
|
||||
{{- if gt $i 0 }} {{ end -}}
|
||||
|
||||
<a class="badge paige-keyword paige-keyword-{{ $kind }} text-bg-secondary text-decoration-none" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a>
|
||||
<a class="badge paige-keyword paige-keyword-{{ $kind }} text-bg-secondary text-decoration-none" href="{{ .RelPermalink | safeURL }}" {{ if $microdata }} itemprop="keywords" {{ end }}>{{ .Title }}</a>
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
</p>
|
||||
@@ -64,7 +65,7 @@
|
||||
{{ range $i, $series := . -}}
|
||||
{{- if gt $i 0 }} · {{ end -}}
|
||||
|
||||
<a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||
<a class="link-secondary" href="{{ .RelPermalink }}" {{ if $microdata }} itemprop="isPartOf" {{ end }}>{{ .Title }}</a>
|
||||
{{- end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
@@ -74,19 +75,19 @@
|
||||
{{ range $i, $author := . -}}
|
||||
{{- if gt $i 0 }} · {{ end -}}
|
||||
|
||||
<a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||
<a class="link-secondary" href="{{ .RelPermalink }}" {{ if $microdata }} itemprop="author" {{ end }}>{{ .Title }}</a>
|
||||
{{- end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{ with $date }}
|
||||
<p class="paige-row-narrow text-center text-secondary" id="paige-date">
|
||||
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time>
|
||||
<time datetime="{{ .Format `2006-01-02` }}" {{ if $microdata }} itemprop="datePublished" {{ end }}>{{ time.Format $dateformat . }}</time>
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{ with $readingtime }}
|
||||
<p class="paige-row-narrow text-center text-secondary" id="paige-reading-time">{{ . }} {{ i18n "paige_minutes" . }}</p>
|
||||
<p class="paige-row-narrow text-center text-secondary" id="paige-reading-time" {{ if $microdata }} itemprop="timeRequired" {{ end }}>{{ . }} {{ i18n "paige_minutes" . }}</p>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
{{ $first := templates.Exists "partials/paige/footer-first.html" }}
|
||||
{{ $last := templates.Exists "partials/paige/footer-last.html" }}
|
||||
{{ $license := $page.Param "paige.license" | markdownify | and ($page.Param "paige.site.disable_license" | not) }}
|
||||
{{ $microdata := $page.Params.paige.page.microdata }}
|
||||
{{ $theme := "https://github.com/willfaught/paige" }}
|
||||
|
||||
{{ $target := partial "paige/target.html" (dict "page" $page "url" $theme) }}
|
||||
@@ -30,7 +31,7 @@
|
||||
{{ end }}
|
||||
|
||||
{{ with $copyright }}
|
||||
<p class="paige-row-narrow text-center text-secondary" id="paige-copyright">{{ . }}</p>
|
||||
<p class="paige-row-narrow text-center text-secondary" id="paige-copyright" {{ if $microdata }} itemprop="copyrightNotice" {{ end }}>{{ . }}</p>
|
||||
{{ end }}
|
||||
|
||||
{{ with $license }}
|
||||
|
Reference in New Issue
Block a user