Hugo type: bug?

Hello guys,
I try to build a little author page where every author can write a little description and below there will be a list of all of his written posts. The URL looks like: “/content/author/{nameslug}/index.md”
In the markdown file I specify the type called author. The HTML file for that lies under “/layouts/author/single.html”. And everything works fine.

The problem is, that if I try to enter “localhost:1313/author/” i’ll get an 404 Error, which makes sense because there is no index file. So I decided to create a “/content/author/index.md” which has also the specified “type: author”. If I open this page I’ll get an overview of the authors which I coded in the single.html file. But now i can’t reach my author pages on “localhost:1313/author/{nameslug}” it just says 404 Error, but the files are existend?

shorted:
“/content/author/{nameslug}/index.md”:

---
type: author
id: ts
name: Tobias
---
my description

“/content/author/index.md”:

---
type: author
---

“/layouts/author/single.html”:

{{ define "main" }}
    {{ $lastUrlElement := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}

                    
    {{ if in $lastUrlElement "author" }}
        <h1>authorList View</h1>
    {{ else }}
        <h1>authorPage View</h1>
    {{ end }}
{{ end }}

But the authorPage (“localhost:1313/author/{nameslug}”) will result in an 404 not found error. If I delete the index.md under “/content/index.md” everything works but the: “localhost:1313/author” page results in an 404 error.

Thank you in advance
Regards

This should be a _index.md file (note the "_"). This will tell Hugo that /author/ is a branch, or list page, and has child pages (/author/author-one/).

When you have content/author/index.md, Hugo treats it as a “single” (or leaf bundle) page. This means that there are no child pages, but instead md files under it are treated as Page Resources.

Consequently, you also need a list.html template that content/author/_index.md will use to render the page.

1 Like

Thank you very much, the underscore fixed everything…

I knew that it can’t be this hard.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.