HUGO

Build Section Page with Content Overview Without Building Content Pages

I have a personal website which I would like to extend by a publications section (e.g., my-site.com/publications). My goal is that Hugo builds /publications.html using all of my publication content files without building a dedicated page for each publication (i.e., /publications/pub1.html should not be built but the content of pub1 should be in the section page).

My question now is: Is this possible? I tried around for a while and could not find any leads in the documentation or the forum. Any pointers to the right search query or solutions are appreciated!

The project structure would like this

root
├── archetypes
│   ├── publications.md
│   └── <other>
├── content
│   ├── publications
│       ├── publication-1.md
│       └── publication-2.md
│   └── <other_content>
├── layouts
│   ├── publications
│       ├── section.html
│       └── single.html  # do I need this?
│   └── <other_layouts>
└── <other>

Just for an example, I have exactly the same operation: I build a page with the list of posts of a specific category, “carnet” below. Here my project structure:

├── config.toml
├── content
│   ├── carnet.md
│   ├── posts
│   │   ├── post-01.md
│   │   ├── post-01.md
---
└── themes
    └── my_theme
        ├── layouts
        │   ├── _default
        │   │   ├── baseof.html
        │   │   ├── carnet.html
---

And the carnet layout, you can add the content with {{ .Content }} in addition to the title:

{{ range  where .Site.RegularPages ".Params.categories" "intersect" (slice "carnet") }}
<li>
    <a href="{{.Permalink}}">
        {{.Title}} — {{ if .Site.Params.dateformShort }}{{ .Date.Format .Site.Params.dateformShort }}{{ else }}{{ .Date.Format "2006-01-02"}}{{ end }}
    </a>
</li>
{{end}}

I hope this can help!

Thank you! That worked like a charm.

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