Blog: paginate the post indexes, and give the Chinese posts working label filtering - #901
Merged
Conversation
/blog/ carried all 101 posts and /zh/ all 112, in one document each. Both now page at 24 posts, five pages apiece, using the same paginated-year-groups shape layouts/events/list.html already uses and the .blog-pagination markup and styles the tag pages already ship. Year headings come from the current pager page, so a year can appear on two consecutive pages. The topic-filter counts still read the full post set, not the current page. Feeds, the sitemap and per-post canonicals are untouched: the feed comes from layouts/_default/list.rss.xml, which does not paginate, and Hugo keeps pager pages out of the sitemap.
✅ Deploy Preview for skywalking-website-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Clicking a topic on /zh/ went to /tags/<term>/, which filters to Section "blog" — so a label counted as 12 Chinese posts opened a page of 15 English ones, with a "back" link to the English blog. Chinese readers had no way to filter their own posts. /zh/ posts share the global `tags` taxonomy with /blog/, and one URL can only render one list, so the Chinese terms cannot live at /tags/<term>/. They are content stubs under content/zh/tags/<slug>/ instead, one per canonical topic in data/blog_topics.yml, carrying the topic name in front matter and rendered by layouts/zh/tagterm.html — filter the Chinese posts first, then page at 12, exactly as the English term page does. The topic menu, the card labels on /zh/ and the labels on Chinese posts all point at the new routes, so the counts in the menu now match what opens. Also adds layouts/tags/list.html. /tags/ had a term layout but no list layout, so the English topic directory rendered as a blank page; it now mirrors the Chinese one at /zh/tags/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/blog/was rendering all 101 posts and/zh/all 112, each in a single document. Both now page at 24 posts, five pages each.Approach
Reuses what the site already has rather than inventing anything:
layouts/events/list.html—.PaginateoverGroupByDate, thenrange $pag.PageGroups.blog-paginationmarkup and styles the tag pages (layouts/tags/term.html) already ship, so no new CSSYear headings come from the current pager page, so a year can appear at the end of one page and the start of the next — same behaviour as the events timeline. The topic-filter counts still read the full post set, not the current page.
Page size
24, chosen against the actual distribution: posts per year run 2–26, so 24 keeps most year groups whole (only 2026, at 26 posts, spills) and suits the 3-up grid at 8 rows. It's one number per file if you'd rather have 12 like the tag pages.
Verification
Clean
hugobuild (rm -rf public resourcesfirst — stale output otherwise lies)./blog//zh/Counted the pre-change build by stashing the diff, so the totals are a measured before/after, not an assumption — no post became unreachable.
Also checked:
layouts/_default/list.rss.xmldoes not paginate;/blog/feed.xmland/zh/feed.xmlstill carry their 20 items.grep -c 'page/[0-9]' public/sitemap.xmlis 0./blog/page/1/is Hugo's standard meta-refresh alias back to/blog/.Note on canonicals
Pager pages canonicalise to
/blog/(and/zh/), becauseseo/meta.htmluses.Permalink, which is the section URL on every pager. That is coherent here — pager pages are absent from the sitemap, and every post carries its own canonical and its own sitemap entry — but it is not the self-referencing canonical Google prefers for paginated series.Making them self-referencing is not a small change, and the failure mode is silent. I tried the obvious fix (
{{ with .Paginator }}inseo/meta.html) and the build still exits 0 while producing a completely empty blog: the head partial runs beforemain, so.Paginatorinitialises a default paginator over.Pagesat pagerSize 10,list.html's.Paginate(groups, 24)then returns that paginator instead of a grouped one,$pag.PageGroupsis empty, and every page renders zero cards across 11 pagers. Left alone deliberately; worth its own change if you want it.Unrelated content bugs spotted
Two
content/zhdirectories produce no page, which is why/zh/shows 112 posts and not 114. Both predate this change and I have not touched them:content/zh/2022-01-24-scaling-with-apache-skywalking/— 10 images, noindex.mdcontent/zh/2026-01-01-skywalking-2025-year-in-review/— empty directory