An archive/list page


#1

I’m moving over from Jekyll and previously I had section under /archives that would list all my posts.

Right now when I go to /post I get something similar, however I want this to be available under /archives instead.

I’ve tried creating a layouts/archive/single.html with the following:

{{ partial "header.html" . }}
{{ partial "navbar.html" . }}


<div class="pure-g">
    <div class="pure-u-1-24 pure-u-md-5-24"></div>
    <div class="pure-u-11-12 pure-u-md-5-8">
        <p class="posts-name">{{ .Title }}:</p>

        <ul class="posts">
            {{ $baseurl := .Site.BaseURL }}
            {{ range $name, $page := .Data.Pages }}
            {{ if eq .Type "post" }}
            <li>
                <a href="{{ .Permalink }}">{{ $page.Title }}</a>

                <p class="footnote">
                    <time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" class="post-list">{{ .Date.Format "Jan 2, 2006" }}</time>

                    {{ if or $page.Params.tags $page.Params.categories $page.Params.series }}
                    to
                    {{ end }}

                    {{ with $page.Params.tags }}
                    tags:[ {{ range $page.Params.tags}}<a href="{{ $baseurl }}tags/{{ . | urlize }}">{{ . }}</a> {{ end }}]
                    {{ end }}


                </p>
            </li>
            {{ end }}
            {{ end }}
        </ul>
    </div>
    <div class="pure-u-1-24 pure-u-md-1-6"></div>
</div>

{{ partial "footer.html" . }}

However it doesn’t render a list of anything. I have to make a content/archives/index.md page to get anything to show up (and then its not a list).

Can someone point me in the right direction?


#2

single.html is for a single piece of content. What you are trying to build is a list of all content.

Hugo is really flexible and such a thing is possible, but it’s not something we’ve given a lot of thought to. I’m sure there are good reasons for wanting this, but I’m curious why /post isn’t acceptable given it’s the same.

The easiest way to accomplish this would be to rename your post type to archive I think