Adding Copyright Notice to the End of Article

Summary

When you browse to the end of the article, you will see a copyright notice. Such a copyright notice can clearly inform the reader of the copyright ownership of the article and the conditions of reproduction/use.

  • If the article is original content:

This article is original content, the copyright belongs to the author. If you need to repost, please declare the title and link of the article.
Article title: PaperMod Theme - Adding Copyright Information —— Rickey
Article link:xxxxxxxxxxx
License:xxx

  • If the article is reprinted content:

This article is a repost, the original information is as follows:
Original title:xxxxxx
Original author:xxxxxxxx
Original link:xxxxxxxxxxx(文章Url) If there is any infringement, please contact the blogger to delete it.

Specific adding steps

1.Add copyright.html

Add a copyright.html file in layouts/partials as follows.

copyright.html
{{ $lang := .Site.Language.Lang }}

<div class="pe-copyright">
    <hr>
    <blockquote>
        {{ if .Param "reposted" }}
        {{ if eq $lang "zh" }}
        <p>本文为转载内容,原文信息如下:</p>
        <p>原文标题:{{- .Param "repostedTitle" -}}</p>
        <p>原文作者:{{- .Param "repostedAuthor" -}}</p>
        <p>原文链接:<a href="{{- .Param " repostedLink" -}}" target="_blank">{{- .Param "repostedLink" -}}</a></p>
        <p>如有侵权,请联系站长删除。</p>
        {{ else }}
        <p>This article is a repost, the original information is as follows:</p>
        <p>Original title: {{- .Param "repostedTitle" -}}</p>
        <p>Original author: {{- .Param "repostedAuthor" -}}</p>
        <p>Original link: <a href="{{- .Param " repostedLink" -}}" target="_blank">{{- .Param "repostedLink" -}}</a></p>
        <p>If there is any infringement, please contact the blogger</a>
            to delete it.</p>
        {{ end }}
        {{ else }}
        {{ if eq $lang "zh" }}
        <p>本文为原创内容,版权归作者所有。如需转载,请在文章中声明本文标题及链接。</p>
        <p>文章标题:{{ .Title }} —— {{ .Param "author" }}</p>
        <p>文章链接:<a href="{{ .Permalink }}" target="_blank">{{ .Permalink }}</a></p>
        <p>许可协议:<a href="{{- .Param " licenseLink" -}}" target="_blank">{{- .Param "licenseName" -}}</a></p>
        {{ else }}
        <p>This article is original content, the copyright belongs to the author. If you need to repost, please declare
            the title and link of the article.</p>
        <p>Article title: {{ .Title }} —— {{ .Param "author" }}</p>
        <p>Article link: <a href="{{ .Permalink }}" target="_blank">{{ .Permalink }}</a></p>
        <p>License: <a href="{{- .Param " licenseLink" -}}" target="_blank">{{- .Param "licenseName" -}}</a></p>
        {{ end }}
        {{ end }}
    </blockquote>
</div>

2.添加 copyright.css

Add a copyright.css file in assets/css/extended as follows.

copyright.css
.pe-copyright {
    margin-top: 20px;
    font-size: 14px;
}

.pe-copyright hr {
    border-style: dashed;
    color: #1e1e33;
}

.pe-copyright blockquote {
    margin: 10px 0;
    padding: 0 10px;
    border-inline-start: 3px solid #1e1e33;
}

.pe-copyright a {
    box-shadow: 0 1px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

3.Adjust single.html

Adjust the single.html file under themes/PaperMod/layouts/_default.

Just insert this code at the appropriate location.

  <!-- Begin. Copyright Notice (below each article) -->
  {{ if .Param "enableCopyright" }}
  {{ partial "copyright.html" . }}
  {{ end }}
  <!-- End. Copyright Notice (below each article) -->

Below is my complete single.html file for your reference.

single.html
{{- define "main" }}

<article class="post-single">
  <header class="post-header">
    {{ partial "breadcrumbs.html" . }}
    <h1 class="post-title entry-hint-parent">
      {{ .Title }}
      {{- if .Draft }}
      <span class="entry-hint" title="Draft">
        <svg xmlns="http://www.w3.org/2000/svg" height="35" viewBox="0 -960 960 960" fill="currentColor">
          <path
            d="M160-410v-60h300v60H160Zm0-165v-60h470v60H160Zm0-165v-60h470v60H160Zm360 580v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q9 9 13 20t4 22q0 11-4.5 22.5T862.09-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z" />
        </svg>
      </span>
      {{- end }}
    </h1>
    {{- if .Description }}
    <div class="post-description">
      {{ .Description }}
    </div>
    {{- end }}
    {{- if not (.Param "hideMeta") }}
    <div class="post-meta">
      {{- partial "post_meta.html" . -}}
      {{- partial "translation_list.html" . -}}
      {{- partial "edit_post.html" . -}}
      {{- partial "post_canonical.html" . -}}
    </div>
    {{- end }}
  </header>
  {{- $isHidden := (.Param "cover.hiddenInSingle") | default (.Param "cover.hidden") | default false }}
  {{- partial "cover.html" (dict "cxt" . "IsSingle" true "isHidden" $isHidden) }}
  {{- if (.Param "ShowToc") }}
  {{- partial "toc.html" . }}
  {{- end }}

  {{- if .Content }}
  <div class="post-content">
    {{- if not (.Param "disableAnchoredHeadings") }}
    {{- partial "anchored_headings.html" .Content -}}
    {{- else }}{{ .Content }}{{ end }}
  </div>
  {{- end }}

  <!-- Begin. Copyright Notice (below each article) -->
  {{ if .Param "enableCopyright" }}
  {{ partial "copyright.html" . }}
  {{ end }}
  <!-- End. Copyright Notice (below each article) -->

  <footer class="post-footer">
    {{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
    <ul class="post-tags">
      {{- range ($.GetTerms $tags) }}
      <li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
      {{- end }}
    </ul>
    {{- if (.Param "ShowPostNavLinks") }}
    {{- partial "post_nav_links.html" . }}
    {{- end }}
    {{- if (and site.Params.ShowShareButtons (ne .Params.disableShare true)) }}
    {{- partial "share_icons.html" . -}}
    {{- end }}
  </footer>

  {{- if (.Param "comments") }}
  {{- partial "comments.html" . }}
  {{- end }}
</article>

{{- end }}{{/* end main */}}

4.Adjust hugo.yaml

Under params add enableCopyright: true, licenseLink, licenseName .

The role added here for new articles written in the future is to add a copyright notice at the bottom of the article by default.

params:
  enableCopyright: true
  licenseLink: "https://creativecommons.org/licenses/by-nc/4.0/"
  licenseName: "CC BY-NC 4.0"

5.Usage

  • Hiding the Copyright Notice

If you don’t want to enable the copyright notice on a specific article, you can add the enableCopyright: false parameter in the article’s Front Matter.

  • Original Articles

If the article is original, you don’t need to make any additional adjustments to the article’s Front Matter.

Of course, if your article does not use the CC 4.0 license, you can add the licenseLink and licenseName parameters to the current article’s Front Matter. This will override the licenseLink and licenseName configurations set in hugo.yaml.

---
licenseName: "GNU LGPL-3.0" # usage GNU LGPL-3.0
licenseLink: "https://opensource.org/license/lgpl-3-0"
---
  • Reposted Articles

If the article is a repost, you need to add the following parameters in the article’s Front Matter:

ParameterDescription
repostedtrue
repostedTitleThe original article’s title
repostedAuthorThe original article’s author
repostedLinkThe original article’s URL
---
reposted: true
repostedTitle: "xxx"
repostedAuthor: "xxxxx"
repostedLink: "xxxxxxxxxxx"
---