fix(plugin): merge case-variant tags into a single archive page#88
Merged
Conversation
The tag slug function downcases and strips non-word characters, so distinct tag strings like "CTF" / "ctf" or "WebAssembly" / "webassembly" both target the same /tag/<slug>/ destination. Previous code generated one page per tag name, which produced a Jekyll build-time "destination is shared by multiple files" conflict and silently dropped the posts of the losing tag from the archive. Group tags by their slug before generating, union and dedup their post lists, and render one paginated page per slug. Picks a canonical display name (prefers the all-lowercase variant) so the `page.tag` Liquid variable stays readable. Verified against the current post set: the /tag/ctf/ archive now lists all three posts (two tagged "ctf", one tagged "CTF") in reverse- chronological order, with no build-time conflict warning.
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.
Summary
_plugins/jekyll-paginate-tags.rbslugifies tag names viatag.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, ''), so distinct tag strings that share a slug (e.g.CTF+ctf,WebAssembly+webassembly) target the same/tag/<slug>/destination.site.tags.keysand emitted one page per tag name, so two tag names that slugified identically produced two pages at the same path. Jekyll loggedConflict: The following destination is shared by multiple filesand the second page silently overwrote the first — dropping the posts of the losing tag from the archive.Concrete example from the current post set
Three posts carry either
ctforCTF:_posts/2012-12-31-29c3-ctf-misc-300-funchive.mdctf_posts/2014-07-01-binary-analysis-next-chapter-of-the-game.mdctf_posts/2018-10-14--flareon2018-chal5-webassembly-writeup-side-channel-attack.mdCTFBefore:
/tag/ctf/listed either two posts or one, depending on hash iteration order, and the build logged a conflict warning. After:/tag/ctf/lists all three in reverse-chronological order.Implementation notes
site.site_payload['site']['tags'](the same Liquid-drop array the old code passed toPager.new), so pagination, templating andpaginator.postskeep their existing shape.post['url']protects against a post tagged with multiple case variants appearing twice on the merged page. Order is re-established viasort_by { |p| p['date'] }.reverse.page.tagin the layout) picks the first all-lowercase variant among the grouped names, falling back to the first seen. This matches the URL slug visually and keeps the rendered page headers readable./tag//.next if slug.empty?removes that edge case._plugins/jekyll-paginate-authors.rbis not affected — authors are keyed by uniqueauthors.ymlusernames, not by free-form tag strings, so the collision pattern doesn't arise there.Validation
Local
bundle exec jekyll build(Jekyll 4.4.1) with the fix:Conflictwarnings._site/tag/<slug>/directories produced._site/tag/ctf/index.htmlcontains links to all three CTF posts (verified with grep)._site/tag/bitcoin/page/{2,3}/pagination still works for high-volume tags.bitcoin,blockchain,cryptocurrency, etc.) render identically to before.Relation to #87
This is the follow-up the Ruby/Jekyll upgrade PR (#87) flagged. Logically independent and applies cleanly on top of current
master. Either order of review/merge works; the upgrade PR does not modify this plugin.