mirror of https://github.com/lxndrblz/anatole.git

techxplorer
19.40.2025 f99b5b1345968a5c160e8432f364f8dc36b78c80
feat: add license metadata (#518)

- New Site.Params.license to include link to license in head
- Use first four digits of copyright for copyrightYear in ld+json

Co-authored-by: Alexander Bilz <mail@alexbilz.com>
3 files modified
20 ■■■■■ changed files
exampleSite/config/_default/params.toml 4 ●●●● patch | view | raw | blame | history
layouts/partials/head.html 4 ●●●● patch | view | raw | blame | history
layouts/partials/schema.html 12 ●●●● patch | view | raw | blame | history
exampleSite/config/_default/params.toml
@@ -30,6 +30,10 @@
# postSectionName = "blog"
# relatedPosts = true
# numberOfRelatedPosts = 3
# Full link to license
#license = "https://creativecommons.org/licenses/by/4.0/"
# disableTitleCapitalization = true
reversepagetitle = true # When set to 'true', the Window Title will be reversed to 'Title | Author' instead of the default 'Author | Title'
layouts/partials/head.html
@@ -137,6 +137,10 @@
  <link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon | relURL }}favicon-16x16.png" />
  <link rel="canonical" href="{{ .Permalink }}" />
  <!-- License -->
  {{- with .Site.Params.license -}}
    <link rel="license" href="{{ . }}"/>
  {{- end -}}
  <!-- RSS -->
  {{ with .OutputFormats.Get "rss" -}}
layouts/partials/schema.html
@@ -7,7 +7,11 @@
      "url": "{{ .Site.BaseURL }}",
      "description": "{{ .Site.Params.description }}",
      "thumbnailUrl": "{{ .Site.Params.Logo | absURL }}",
      "license": "{{ .Site.Params.Copyright }}"
      "license": "{{ .Site.Params.license}}"
      {{ with .Site.Params.copyright }}
        {{ $copyright := replace . "{{ YEAR }}" (now.Format "2006") }}
        ,"copyrightYear": "{{ index (findRE `^\d{4}` $copyright 1) 0 }}"
      {{ end }}
    }
  </script>
{{ else if .IsPage }}
@@ -34,6 +38,11 @@
    {{ end }}",
        "license": "{{ .Site.Params.license}}",
        {{ with .Site.Params.copyright }}
          {{ $copyright := replace . "{{ YEAR }}" (now.Format "2006") }}
          "copyrightYear": "{{ index (findRE `^\d{4}` $copyright 1) 0 }}",
        {{ end }}
        "inLanguage": {{ .Site.LanguageCode | default "en-us" }},
        "isFamilyFriendly": "true",
        "mainEntityOfPage": {
@@ -56,7 +65,6 @@
            "@type": "Person",
            "name": "{{ $author }}"
        },
        "copyrightYear" : "{{ .Date.Format "2006" }}",
        "dateCreated": "{{ .Date.Format "2006-01-02T15:04:05.00Z" | safeHTML }}",
        "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05.00Z" | safeHTML }}",
        "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05.00Z" | safeHTML }}",