Hugo 不显示子目录中的页面 [File.Dir]

Hugo doesn't show pages in a subdirectory [File.Dir]

当我将文件添加到主内容目录时,一切正常。 .md post 文件出现了,但是当我将文件放入子目录时。 {{ range (where .Pages "File.Dir" "in" "/articles/") }} 代码什么也没做。什么都没有出现。我包含了我网站的 index.html 文件的一部分以供更广泛的参考。我有一个文章文件夹 (/content/articles/),里面有多个 .md 文件。我是 运行 雨果 windows 10。

感谢您的帮助

<div class="row" id="articles">
        <div class="col-sm-12">
            <h3 class="category_header">Articles</h3>
            <div class="article_list card-body">
                    <ul>
                        {{ range (where .Pages "File.Dir" "in" "/articles/") }}
                        <li>
                            {{ .PublishDate.Format "Jan 2006" }} -
                            <a href="{{.Permalink}}">{{.Title}}</a>
                        </li>
                        {{ end }}
                    </ul>
            </div>
        </div>
    </div>

编辑:我认为这与 windows 路径有关。我在 Ubuntu 上重新创建了我的网站,但没有遇到同样的问题。

我无法在我的 windows 10 盒子上复制这个。

但一般来说,您可能应该使用

{{ range .Section "articles" }}

相反。

发布这个问题后,我切换到 Ubuntu,我的博客似乎运行良好,忘记了这个问题的存在,直到我决定再次使用 windows 机器。现在我通过 hugo 支持论坛了解到这是 File.Dir 变量的原因。引用答案 in the hugo support forum: 在 UNIX 中 File.Dir 变量产生 /notebooks/ 而在 Windows 中它将产生 \notebooks\

所以替换

{{ range (where .Pages "File.Dir" "in" "/articles/") }}

至:

{{ range (where .Pages "File.Dir" "in" "\articles\") }}

已修复。