Reputation: 1937
I don't want to display the list page for the about. localhost/about
should not even exist. Ideally I would like to not have an _index.md
file but Hugo complains if I don't have one.
Content directory "/work/content/about" have both index.* and _index.* files, pick one.
.File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
I am trying to have the following hierarchy
content
-- about
-- use-cases
_index.md
--some-use-case
index.md
-- faq
index.md
I should be able to access localhost/about/use-cases
or localhost/about/faq
but not the localhost/about
. Is there a way to achieve this?
Upvotes: 2
Views: 1279
Reputation: 1791
There's more than one way to do this, but the v0.65.0+ way is to use Hugo's
Build Options. Here's how I do it: First add the about/_index.md
that the arrow points to below so your directory structure looks like this:
content
-- about
_index.md <-- discussed below!
-- use-cases
_index.md
--some-use-case
index.md
-- faq
index.md
In this about/_index.md
file put the following front matter.
---
cascade:
_build:
render: always
list: always
_build:
render: never
list: never
---
This is enough to make localhost/about/
not exist and the content below it exist (that's what the cascade
part does). If you want to redirect it somewhere you can include the following in the front matter of the page that you want to redirect it to:
---
aliases:
- /about/
---
For example, if you want to redirect it to your home page, put the above aliases
list in content/_index.md
.
content
_index.md <-- home page metadata & content!
-- about
_index.md
⋮
Upvotes: 3