【问题标题】:Link to next post链接到下一个帖子
【发布时间】:2017-10-26 11:22:56
【问题描述】:

我在content中的结构:

content
|-post
| |-00.md
| |-01.md
| |-02.md
|-about.md

在帖子的单个模板中,我希望有一个页脚:

  • 是指向下一篇文章的链接,或者,如果没有下一篇文章可用
  • 是文本“待续”。

在伪模板代码中意味着:

{{ if nextpost.exists }} #. becomes nexpost here
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}

nextpost 是 currentpost+1


如何创建这种链接?

【问题讨论】:

    标签: hugo


    【解决方案1】:

    听起来你想要.NextInSection 变量。如果你使用with 函数,你可以让它像你想要的那样工作。

    {{ with .NextInSection }}
      <a href="{{ .Permalink }}">{{ .Title }}</a>
    {{ end }}
    

    您也可以以类似的方式使用.PrevInSection

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 2013-04-24
      • 1970-01-01
      相关资源
      最近更新 更多