Skip to content

Blog: paginate the post indexes, and give the Chinese posts working label filtering - #901

Merged
wu-sheng merged 2 commits into
masterfrom
feat/blog-pagination
Aug 19, 2026
Merged

Blog: paginate the post indexes, and give the Chinese posts working label filtering#901
wu-sheng merged 2 commits into
masterfrom
feat/blog-pagination

Conversation

@wu-sheng

Copy link
Copy Markdown
Member

/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:

  • the paginated-year-groups shape from layouts/events/list.html.Paginate over GroupByDate, then range $pag.PageGroups
  • the .blog-pagination markup and styles the tag pages (layouts/tags/term.html) already ship, so no new CSS

Year 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 hugo build (rm -rf public resources first — stale output otherwise lies).

/blog/ /zh/
pager pages 5 5
cards across all pagers 101 112
cards before this change 101 112

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:

  • Feeds unaffectedlayouts/_default/list.rss.xml does not paginate; /blog/feed.xml and /zh/feed.xml still carry their 20 items.
  • Sitemap unaffected — Hugo excludes pager pages; grep -c 'page/[0-9]' public/sitemap.xml is 0.
  • /blog/page/1/ is Hugo's standard meta-refresh alias back to /blog/.

Note on canonicals

Pager pages canonicalise to /blog/ (and /zh/), because seo/meta.html uses .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 }} in seo/meta.html) and the build still exits 0 while producing a completely empty blog: the head partial runs before main, so .Paginator initialises a default paginator over .Pages at pagerSize 10, list.html's .Paginate(groups, 24) then returns that paginator instead of a grouped one, $pag.PageGroups is 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/zh directories 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, no index.md
  • content/zh/2026-01-01-skywalking-2025-year-in-review/ — empty directory

/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.
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for skywalking-website-preview ready!

Name Link
🔨 Latest commit 8872646
🔍 Latest deploy log https://app.netlify.com/projects/skywalking-website-preview/deploys/6a8515d4b954cd00095f1a97
😎 Deploy Preview https://deploy-preview-901--skywalking-website-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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/.
@wu-sheng wu-sheng changed the title Blog: paginate the English and Chinese post indexes Blog: paginate the post indexes, and give the Chinese posts working label filtering Aug 19, 2026
@wu-sheng
wu-sheng merged commit 34fe3bb into master Aug 19, 2026
4 of 5 checks passed
@wu-sheng
wu-sheng deleted the feat/blog-pagination branch August 19, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant