Display posts from another section with paging

Hi, I am trying to write code in “moto” list.html section. I would like to display all pages from “auta” section with paging. So, I need to display posts from another section with paging.

I am not sure, why it’s not working with pagination.

Not working code with pagination:

{{ $cars := (where .Site.AllPages ".Section" "auta") }}

{{ $paginator := .Paginate $cars }}

{{ range $paginator.Pages}}

<div class="col-xl-3 col-lg-4 col-sm-6">

    <a href="{{ .RelPermalink }}"></a>

  </div>

  {{ end}}

Working code without pagination:

{{ $cars := (where .Site.AllPages ".Section" "auta") }}

{{ range $cars }}

<div class="col-xl-3 col-lg-4 col-sm-6">

    <a href="{{ .RelPermalink }}"></a>

  </div>

  {{ end}}

Where’s the problem?

Please, help me. Thank you very much

Your anchor element doesn’t contain content, so it will be blank in the browser.

I’ve cut content.

Full:

<div class="col-xl-3 col-lg-4 col-sm-6">

      <a href="{{ .RelPermalink }}">

      <div class="product">

        <div class="product-image">

            {{ with .Params.featuredImage }}

            <img loading="lazy" class="img-fluid" src="{{ . }}" alt="product"/>

            {{ else }}

            <img loading="lazy" class="img-fluid" src="/img/placeholder.png">

            {{ end }}    

        </div>

       

        <div class="py-2">

          <h3 class="h6 text-uppercase mb-1"><a class="text-dark product-name" href="{{ .RelPermalink }}">{{ .Title }}</a></h3>

          <span class="text-muted">

            {{ $.Scratch.Set "num" .Params.Price  }}

            {{ partial "prettynum.html" . }} Kč

          </span>

        </div>

      </div>

    </a>

  </div>

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.

See https://discourse.gohugo.io/t/requesting-help/9132.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

The problem has been solved. .Paginate can be only one time on same page.

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