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 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.


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