如何使跨页引用在Hugo工作?



我有一个基于这个主题的hugo项目设置,并具有以下项目结构。

content
learning
aws
index.md
how-we-use
index.md

aws > index.md文件中,我想要有一个打开how-we-use > index.md的链接。我在下面试了一下(还有很多其他的东西),但是每次我点击它,它都给我404。

尝试以下aws > index.md

- [How we use AWS](./how-we-use)
- [How we use AWS](/how-we-use)
- [How we use AWS](/learning/aws/how-we-use)
下面是我的how-we-use > index.md
+++
title = "How we use AWS"
aliases = "/learning/aws/how-we-use/"
+++
Hi There

另外,尝试将此别名更改为/how-we-use//how-we-use,但仍然不起作用。

config.toml

baseurl = "https://welcome-page" 
title = "welcome"
theme = "hugo-universal-theme"
themesDir = "./themes"
languageCode = "en-us"
uglyURLs = false
# Site language. Available translations in the theme's `/i18n` directory.
defaultContentLanguage = "en"
# Define the number of posts per page
paginate = 10
# not pluralize title pages by default
pluralizelisttitles = false
[[menu.main]]
name       = "Learnings"
identifier = "menu.learnings"
url        = "/img/learnings.png"
weight     = 4
[[menu.main]]
name       = "Learnings"
identifier = "section.learnings"
url        = ""
weight     = 1
parent     = "menu.learnings"
post       = 1

[[menu.main]]
name       = "AWS"
identifier = "learning.aws"
url        = "/aws"
weight     = 1
parent     = "section.learnings"

如何让这个交叉引用工作?

p。s -如果我将文件的名称更改为_index.md,则没有内容显示,我只看到标题显示,但没有其他内容。

md链接格式[]()可以与完整链接[](https://...)或锚[](#anchor)一起使用,但您需要相对链接,hugo有另一种语法:[]({{< ref "" >}})

根据Hugo文档索引。可以通过其路径或包含其的文件夹引用Md,但不以/结尾。_index。Md只能被包含它的文件夹引用。

所以试试吧:

  • [How we use AWS]({{< ref "/how-we-use" >}})

它适用于我的ananke主题。但你也可以试试:

  • [How we use AWS]({{< ref "/how-we-use/index" >}})
  • [How we use AWS]({{< ref "/learning/aws/how-we-use" >}})
  • [How we use AWS]({{< ref "/learning/aws/how-we-use/index" >}})

最新更新