gpt4 book ai didi

permalinks - Hugo 中的部分层次结构

转载 作者:行者123 更新时间:2023-12-04 15:49:49 25 4
gpt4 key购买 nike

我正在尝试在 Hugo + blogdown 中构建永久链接结构,其中帖子将具有

的永久链接结构

网站名称/类别/slug

不确定如何执行此操作,因为我已将 config.toml 永久链接结构设置为

    [permalinks] 
posts = "/:section/:slug"

然后我将帖子(一个 .md 文件)放入帖子文件下方的一个类别文件夹中,但我得到一个类似于 websitename/posts/category/slug.. . 当我真正想要的是 websitename/category/slug 时。

我希望将类别设为部分,但 URL 中没有“post”。

我仍在尝试找出放置 _index.md 文件的位置,但不是很成功。任何帮助,将不胜感激。

最佳答案

永久链接是在每个部分 的基础上设置的。 sections是content下的一级目录,不是content/posts/下的。

因此,如果您希望永久链接是 websitename/category/slug,请像这样安排类别目录(或 Hugo 术语的 sections):

content
├── category1
│   └── 2015-01-04-first-post.md
├── category2
│   └── 2015-01-27-dear-diary.md
├── _index.md
├── page
│   └── about.md
└── post
├── 2017-03-07-bigimg-sample.md
└── 2017-03-20-photoswipe-gallery-sample.md

并设置

[permalinks] 
category1 = "/:section/:slug"
category2 = "/:section/:slug"
page = "/:section/:slug"
post = "/:section/:slug"

在你的 config.yaml 中

来源:https://gohugo.io/content-management/urls/#permalinks

关于permalinks - Hugo 中的部分层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54299339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com