【问题标题】:Hugo - Access .Pages from the context of the list template from within the context of the single templateHugo - 从单个模板的上下文中的列表模板的上下文中访问 .Pages
【发布时间】:2018-08-03 05:41:32
【问题描述】:

hugo 的文档说,单个页面上下文中的 .Pages 变量是空白的,并且列表页面上下文中的 .Pages 变量已填充。

我想在单个页面的上下文中从列表页面访问 .Pages 变量。

我该怎么做?

文档如下:

【问题讨论】:

    标签: hugo


    【解决方案1】:

    解决了这里的问题是我想出的。这个sn-p:

     {{ $currentPage := . }} 
    {{ range .Site.Pages }}
        {{ if .InSection $currentPage}} 
            {{ if .IsAncestor $currentPage }} 
                {{ else }}
                    <li>
                        <a class="nav-link active" href="{{.Permalink}}">{{.Title}}</a>
                    </li>
            {{ end }} 
        {{ end }} 
    {{ end }}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-26
      • 1970-01-01
      • 2015-05-06
      相关资源
      最近更新 更多