How to show the list.html in the home page of the hugo site

I created a simple loop through posts in in list.html. In the browser when I go to http://localhost:1313/posts/ it works correctly. But I want this to be part of the http://localhost:1313.
I tried to make this a main block and used in baseof.html as

   	{{- block "main" . }}{{- end }}

but still nothing.

What about your index.html?

When I run the following code in the index.html it doesn’t show anything properly it just shows the word “posts” with a date! instead of showing actual posts. it just mentions the posts folder I guess.

{{ $paginator := .Paginate (where .Pages "Type" "posts") }}

{{ range  $paginator.Pages  }}


<p class="article-detail-date">{{ .Date.Format "January 2, 2006" }}</p>
<p>{{ .Summary | plainify | safeHTML }}</p>

{{ if .Truncated }}
<a href="{{ .Permalink }}">Read more</a> 
{{ end }}


{{ end }}

<div class="page-nav">

  {{ if .Paginator.HasPrev }}
  <a href="{{ .Paginator.Prev.URL }}">
    {{- partial "svg/icons" "chevron-left" -}} Newer
  {{ else }}
  {{ end }}

  {{ if .Paginator.HasNext }}
  <a href="{{ .Paginator.Next.URL }}">
    Older {{- partial "svg/icons" "chevron-right" -}}
  {{ end }}


while the /posts is showing properly

Could you try to replace .Pages with .Site.RegularPages?

1 Like

It worked. Why?

Context (.Something =/= .Site.Something).

1 Like


1 Like

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