美文网首页
Hugo blackburn版本升级

Hugo blackburn版本升级

作者: 戈壁堂 | 来源:发表于2020-10-24 19:37 被阅读0次

写的时候Hugo版本还是0.34,现在最新版本已经是0.76。升级后生成的静态站点主页一直未空,log提示下面两个问题——

  • Page.Hugo is deprecated and will be removed in a future release. Use the global hugo function.

  • Page.RSSLink is deprecated and will be removed in a future release. Use the Output Format's link, e.g. something like: {{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}

在论坛和github issue里都可以查到对应的问题。

第一个问题:issues #1017Page’s .Hugo is deprecated as of 0.55.0

第二个问题:issue #4427Page.Hugo is deprecated / Page.RSSLink is deprecated

都指向同一个文件:head.huml

删除{{.Hugo.Generator}},或修改为{{hugo.Generator}}以解决第一个问题;

第二个问题针对RSSLink的定义,例如——

  {{ if .RSSLink }}
  <link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" href="{{ .RSSLink }}" />
  {{ end }}

修改为——

  {{ if .OutputFormats.Get "RSS" }}
  <link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}"
    href='{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}' />
  {{ end }}

social.html文件中也涉及到第二个问题的处理——

{{ if .RSSLink }}
    <li class="pure-menu-item">
      <a class="pure-menu-link" href="{{ .RSSLink }}"><i class="fa fa-rss fa-fw"></i>RSS</a>
    </li>
    {{ end }}

修改为——

    {{ if .OutputFormats.Get "RSS" }}
    <li class="pure-menu-item">
      <a class="pure-menu-link" href='{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}'><i
          class="fas fa-rss"></i>RSS</a>
    </li>
    {{ end }}

另外一个更简单的版本就是:升级使用的主题(例如我使用的这个blackburn主题的最新版本已经针对新版hugo做了优化处理)

升级后对应的CI文件wrecker.yml中使用的版本也需要做对应的更新,最新版本为0.74.3

处理完还能继续支持一段时间,Github Action再议:(

相关文章

网友评论

      本文标题:Hugo blackburn版本升级

      本文链接:https://www.haomeiwen.com/subject/vgnkmktx.html