禁用雨果中的页面嵌套 /内容部分,并在顶级发布所有页面?

发布于 2025-01-25 05:36:42 字数 1003 浏览 1 评论 0 原文

自从我上次使用雨果以来已经有5年了,所以我忘记了很多东西,也许有些事情也发生了变化。

我使用Hugo发布静态博客,由于某些原因,所有内容都在您必须单击的“帖子”部分下发布,此时页面为“ #posts”。我不记得以前发生这种情况。

我尝试了 使用 - disable> - disables = pection 为了成功阻止“ Post”出现在我的主页上,但孩子们的页面也消失了。除了希望我的博客文章出现在我的主页上,我还希望URL结构反映该校正后的组织;即,现在所有内容都在 mywebsite.com/post/article-name-here 下出现在 mywebsite.com/article-name-here 时。]

在我的存储库中,我的博客文章实际上被存储在 content/post/acters-name-here 下,但是当我将文章直接移至 content 目录中时,雨果失败了显示它们。

我觉得这应该是一个非常简单的修复,但是我显然没有使用正确的搜索词来描述正在发生的事情。

请让我知道我还可以提供哪些其他信息,因为我很难阐明正在发生的事情。

It's been 5 years since I've last used Hugo, so there is a lot I am forgetting and perhaps some things have changed as well.

I use Hugo to publish a static blog, and for some reason everything is being published under a "Post" section that you have to click into, at which point the page is title "#Posts". I do not recall this ever happening before.

I tried using --disableKinds=section to successfully stop "Post" from showing up on my main page, but the children pages disappeared as well. In addition to wanting my blog posts to show up on my main page, I want the URL structure to reflect this corrected organization; i.e., right now everything is showing up under mywebsite.com/post/article-name-here when it should just be mywebsite.com/article-name-here.]

Within my repository, my blog articles are in fact stored under content/post/article-name-here, but when I moved my articles into the content directory directly, Hugo failed to display them.

I feel like this should be a very easy fix, but I'm clearly not using the right search terms to describe what is going on.

Please let me know what other information I can provide as I am having a hard time articulating what is going on.

Main Hugo page with incorrectly displayed "Posts" article that leads to my actual posts.

Articles I want to appear at my top-level URL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月竹挽风 2025-02-01 05:36:42

设置永久链接

现在,所有内容都在 mywebsite.com/post/article-name-here 下显示在 mywebsite.com/article-name-here /p>

您使用时 时一个config.yaml文件,您可以将其添加到其中:

permalinks: 
  posts: /:filename

从您的URL中消除 post/。对于 .toml ,您必须稍微更改格式。

主页解决方案

如果您在来自:

{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

进入:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}

...您将获得预期的结果(主页上的帖子列表)。我测试了它。

Setting the permalink

right now everything is showing up under mywebsite.com/post/article-name-here when it should just be mywebsite.com/article-name-here

When you are using a config.yaml file, you can add this to it:

permalinks: 
  posts: /:filename

That will eliminate the post/ from your URL. For .toml you have to slightly alter the formatting.

The homepage solution

If you change line 8 in your layouts/index file from:

{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

into:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}

... you will get the expected result (a list of your posts on the homepage). I tested it.

拔了角的鹿 2025-02-01 05:36:42

这是我为雨果先生在上方/下方的答案所做的临时解决方案:

  • 设置 permalink configuration < /a>在我的config.toml文件中,如雨果先生所述。
  • SET url =“ Artist-Name-Here” 在每个博客文章的标记文件中。
  • 使用 Hugo 通过命令行发布,在 Publish/post/post/post 目录中以index.html和index.xml文件,然后将它们移至 publish 目录(即,已经在那里覆盖index.html和index.xml文件)。
  • 手动将 H1 标签的内容从“ #posts”到“最近的文章”。

希望我能找到一个更好的答案,并一旦我做到了这个堆栈溢出问题。

Here is the temporary solution I worked out thanks to Mr. Hugo's answer above/below:

  • Set the permalink configuration in my config.toml file as Mr. Hugo noted.
  • Set url = "article-name-here" inside every blog post's Markdown file.
  • Publish using hugo via command line, take the index.html and index.xml files within the publish/post directory, and move them into the publish directory (i.e., overwrite the index.html and index.xml files already there).
  • Manually retitle the content of the h1 tag inside index.html from "#Posts" to "Recent Articles".

Hopefully I can figure out a better answer and update this Stack Overflow question once I do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文