Change homepage via front matter

I’m running into a hit/miss issue with setting the homepage.

I don’t have a “homepage” but instead want my homepage to be the “articles” list. I went into the _index.md file in my articles folder and set the url: “/”

This works sometimes and then others it will default to displaying the index.html file from the layouts folder.

Is there a better way to set a section or page to be the homepage?

Yes. Use a home page template.

layouts/index.html:

{{ define "main" }}
  <main>
    {{ .Content }}
    {{- range (.Paginate (where .Site.RegularPages "Type" "articles")).Pages }}
    <section>
      <h2 id="{{ .Title | anchorize }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
      <p>{{ .Summary }}</p>
      {{- if .Truncated }}
      <p><a href="{{ .RelPermalink }}">Continue reading...</a></p>
      {{- end }}
    </section>
    {{- end -}}
    {{- if gt .Paginator.TotalPages 1 }}
    <nav>
      {{ template "_internal/pagination.html" . }}
    </nav>
    {{- end }}
  </main>
{{ end }}
1 Like