hyde
hyde copied to clipboard
Pagination
Go Hyde uses Poole, which has styling for pagination:
https://github.com/spf13/hyde/blob/62d338fedbf909178823a299e79d14a947ac6335/static/css/poole.css#L354-L359
Poole utilizes this pagination for Jekyll:
https://github.com/poole/poole/blob/c0d52e1e/index.html#L22-L33
as does Jekyll Hyde:
https://github.com/poole/hyde/blob/7c7f7550/index.html#L22-L37
but Go Hyde doesnt utilize the pagination:
https://github.com/spf13/hyde/blob/62d338fedbf909178823a299e79d14a947ac6335/layouts/index.html#L1-L18
As a workaround, I swapped out the Poole pagination CSS for this:
https://github.com/gohugoio/hugo/blob/c0d7188e/docs/themes/gohugoioTheme/assets/css/_hugo-internal-template-styling.css#L2-L27
Then edit the layout:
diff --git a/layouts/index.html b/layouts/index.html
index ec6d2eb..8ac316e 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -1,6 +1,6 @@
{{ define "main" -}}
<div class="posts">
-{{ range .Site.RegularPages -}}
+{{ range .Paginator.Pages -}}
<article class="post">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title }}</a>
@@ -15,4 +15,5 @@
</article>
{{- end }}
</div>
+{{- template "_internal/pagination.html" . }}
{{- end }}
Also the default list of pages includes posts as well as pages and it seems to be a giant mess.
I saw in a different theme (blackburn) that they were instead ranging over this, which makes way more sense, giving us just a list of posts.
...
{{ range ( .Paginate (where .Site.RegularPages "Type" "post")).Pages -}}
...
Also the default list of pages includes posts as well as pages and it seems to be a giant mess.
Not sure what you mean by "posts as well as pages"... but if you want to change the paginator for the home page, you need to use the .Params.mainSections
slice to do the filtering. This is a theme and not all people have posts
as a section.
Ah, got that. I didn't realize that posts are not present by default.
But is the expectation that the default output of index.html will be: a) All the pages b) All types of pages? (Post, regular pages, etc). By mistake was assuming that the most common case was blogs with a mix of posts and pages, and the default view that of a list of posts and pages as links on the sides. But you are right. I have seen quite a few blogs, which are just a collection of pages without any post.
If you use .Params.mainSections
it will get a sensible default that you can override if you want.