How to create a single page with links to all posts?

Hello, I have been doing research on this all morning and something isn’t clicking. I have been building a site with Hugo where I would like to have a single page with links to all the posts. I have done this before and I cannot for the life of me figure out how to do it again. From what I remember it was incredibly simple. I believe what I am looking for is taxonomies but for some reason I cannot figure this out even after reading the documentation.

This is the desired output I am looking for.

Currently the only way I am able to get this to work is by adding these Hugo variables to the themes/doctor/layouts/page/single.html file.

    <ul class="posts">
       {{ $section := where site.RegularPages "Type" "in" site.Params.mainSections }}
       {{ range first 200 $section }}
        <li>
          <a href="{{ .Page.Permalink }}">{{ .Title }}</a>
        </li>
      {{ end }}
    </ul>
 </div>

Obviously the problem with this is that it would work fine for a single page, it is going to add those Hugo variables to ALL pages. (I know this is by design and I should not be editing single.html for what I am looking for. Any help would be greatly appreciated. I’m not sure why I’m having a hard time trying to comprehend what seems to be a simple task.
Here is the project tree if this helps!

Thanks!!!

├── archetypes
│   └── default.md
├── config.toml
├── content
│   ├── _index.md
│   ├── page
│   │   ├── advanced-use.md
│   │   ├──Guides.md
│   │   ├── Resources.md
│   │   └── What-Is-This-Site.md
│   └── post
│       ├── post1.md
│       └── post2.md
├── data
├── layouts
│   └── _default
├── public
│   ├── assets
│   │   ├── css
│   │   │   ├── normalize.css
│   │   │   └── syntax.css
│   │   └── js
│   │       └── respond.min.js
│   ├── categories
│   │   ├── index.html
│   │   └── index.xml
│   ├── index.html
│   ├── index.xml
│   ├── logo.png
│   ├── main.min.b9b4c1c0e8363069717b02cd96aca2e4569ccc720613240ed6fb04b9d0ddec3c.css
│   ├── page
│   │   ├── about
│   │   │   └── index.html
│   │   ├── advanced-use
│   │   │   └── index.html
│   │   ├── getting-started
│   │   │   └── index.html
│   │   ├── index.html
│   │   └── index.xml
│   ├── post
│   │   ├── emoji-support
│   │   │   └── index.html
│   │   ├── index.html
│   │   ├── index.xml
│   │   ├── placeholder-text
│   │   │   └── index.html
│   │   ├── rich-content
│   │   │   └── index.html
│   │   ├── guide
│   │   │   └── index.html
│   │   └── guide2
│   │       └── index.html
│   ├── sitemap.xml
│   └── tags
│       ├── emoji
│       │   ├── index.html
│       │   └── index.xml
│       ├── index.html
│       ├── index.xml
│       ├── markdown
│       │   ├── index.html
│       │   └── index.xml
│       ├── privacy
│       │   ├── index.html
│       │   └── index.xml
│       ├── shortcodes
│       │   ├── index.html
│       │   └── index.xml
│       └── text
│           ├── index.html
│           └── index.xml
├── resources
│   └── _gen
│       ├── assets
│       │   └── scss
│       │       └── sass
│       │           ├── template.scss_a4f67715571c07e60af265b7eb62fb3e.content
│       │           └── template.scss_a4f67715571c07e60af265b7eb62fb3e.json
│       └── images
├── static
│   └── logo.png
└── themes
    └── docter
        ├── archetypes
        │   ├── page.md
        │   └── post.md
        ├── assets
        │   └── sass
        │       └── template.scss
        ├── exampleSite
        │   ├── config.toml
        │   ├── content
        │   │   ├── _index.md
        │   │   ├── page
        │   │   │   ├── advanced-use.md
        │   │   │   ├── getting-started.md
        │   │   │   └── intermediate-use.md
        │   │   └── post
        │   │       ├── emoji-support.md
        │   │       ├── markdown-syntax.md
        │   │       ├── placeholder-text.md
        │   │       └── rich-content.md
        │   └── resources
        │       └── _gen
        │           └── assets
        │               └── scss
        │                   └── sass
        │                       ├── template.scss_a4f67715571c07e60af265b7eb62fb3e.content
        │                       └── template.scss_a4f67715571c07e60af265b7eb62fb3e.json
        ├── images
        │   ├── screenshot.png
        │   └── tn.png
        ├── layouts
        │   ├── 404.html
        │   ├── _default
        │   │   ├── baseof.html
        │   │   └── list.html
        │   ├── index.html
        │   ├── index.html.bak
        │   ├── page
        │   │   ├── guide.html
        │   │   ├── single.html
        │   │   └── single.html.bak
        │   ├── partials
        │   │   ├── footer.html
        │   │   ├── header.html
        │   │   ├── head.html
        │   │   └── sidebar.html
        │   └── post
        │       ├── list.html
        │       └── single.html
        ├── LICENSE
        ├── README.md
        ├── static
        │   └── assets
        │       ├── css
        │       │   ├── normalize.css
        │       │   └── syntax.css
        │       └── js
        │           └── respond.min.js
        └── theme.toml

What is the path to the markdown file that should list the pages?

mysite/content/page/Guide.md

You have two options…

Shortcode

Create a shortcode that lists the pages, and call the shortcode from page/Guide.md

Layout

Create a unique layout to be used by this page only (e.g., layouts/page/foo.html, then specify layout = "foo" in the front matter of page/Guide.md.

Worked like a charm. Thanks!!!

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