需求:自定义页面底部信息,添加版权说明关于我两个页面链接

  1. ./themes/PaperMod/layouts/partials/footer.html 复制到./layouts/partials/footer.html
  2. 新建自定义底部信息模板
./layouts/partials/footer_info.html
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<!-- 将 footer.html 中 <footer> 的代码移至 footer_info.html -->
<footer class="footer">
    {{- if site.Copyright }}
    <span>{{ site.Copyright | markdownify }}</span>
    {{- else }}
    <span>&copy; {{ now.Year }} <a href="{{ "" | absLangURL }}">{{ site.Title }}</a></span>
    {{- end }}
    <span>
        Powered by
        <a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
        <a href="https://github.com/loyayz/hugo-PaperModx/" rel="noopener" target="_blank">PaperModx</a>
    </span>
</footer>
  1. 编辑模板
./layouts/partials/footer.html
1
2
3
4
<!-- 添加引用 footer_info.html -->
{{- if not (.Param "hideFooter") }}
{{- partial "footer_info.html" . }}
{{- end }}
./layouts/partials/footer_info.html
1
2
3
4
5
6
7
8
9
<footer class="footer">
    <span>&copy; {{ now.Year }} <a href="/about/">loyayz</a></span>
    <span>
        Powered by
        <a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
        <a href="https://github.com/loyayz/hugo-PaperModx/" rel="noopener" target="_blank">PaperModx</a>
    </span>
    <span>·&nbsp;<a href="/copyright/">版权说明</a></span>
</footer>

注:可以直接修改./layouts/partials/footer.html,我是为了方便后续修改而这样拆分