zwbetz-gh / cupper-hugo-theme

An accessibility-friendly Hugo theme, ported from the original Cupper project.
https://cupper-hugo-theme.netlify.app/
MIT License
301 stars 190 forks source link

Blog list on Home #20

Closed Sadmansamee closed 4 years ago

Sadmansamee commented 4 years ago

I want to show all the posts on Home instead of _index.md contents so that whenever website loads it will show all the blog posts. How would I do that?

zwbetz-gh commented 4 years ago

Replace the contents of file layouts/index.html with:

{{ define "main" }}
  <main id="main">
    <h1>{{ .Title }}</h1>
    <ul class="patterns-list">
    {{ $pages := where site.RegularPages "Section" "==" "post" }}
    {{ range $pages.ByPublishDate.Reverse }}
      <li>
        <h2>
          <a href="{{ .Permalink }}">
            <svg class="bookmark" aria-hidden="true" viewBox="0 0 40 50" focusable="false">
              <use xlink:href="#bookmark"></use>
            </svg>
            {{ .Title }}
          </a>
        </h2>
      </li>        
    {{ end }}
    </ul>
  </main>
{{ end }}
Sadmansamee commented 4 years ago

Thanks, it worked wonderfully.