Data Files and Pagination

I am generating a projects list on my blog. The data for the projects is in a data folder. Currently I use

{{ range sort $.Site.Data.projects “Id” “desc” }}

to iterate over all the projects and displaying them on /projects.

I want to add pagination. Looking at the Paginator documentation, something like this should work

{{ $paginator := .Paginate (sort $.Site.Data.projects “Id” “desc”) }}
{{ range .Paginator.Pages }}

I also tried

{{ $paginator := .Paginate (sort $.Site.Data.projects “Id” “desc”) }}
{{ range $paginator.Pages }}

but no luck either. Any ideas how to achieve this?

The paginator only works for pages.

How did you solve this problem? Looking forward to hearing your alternative solutions for it :slight_smile: @bep

I solved it using pages instead. I created a subfolder called projects in the content directory, added the projects there as pages and then made all the templates showing blog posts ignore this folder.

@Igor_Kulman Thanks for your help:-) seems no other route to achieve what you mentioned on topic.

Hello @bep

Any news about that ? Does paginator still only works for pages !!! not for Data ??

Thanks

No news.

This topic was automatically closed after 26 hours. New replies are no longer allowed.