feat: support i18n_subsites and fix sitemap format - #48
Open
diegofd wants to merge 1 commit into
Open
Conversation
diegofd
marked this pull request as ready for review
January 2, 2026 21:06
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.
Add i18n_subsites support for proper hreflang generation
Problem
The sitemap plugin doesn't properly support the
i18n_subsitesPelican plugin. When usingi18n_subsites, each language runs as a separate Pelican instance with its ownSITEURL(e.g.,https://example.comfor the main language andhttps://example.com/enfor subsites). This caused several issues:i18n_subsitesdoesn't populateobj.translations- each language version is processed independentlySITEURLper language../segments that weren't normalizedSolution
This PR adds proper i18n_subsites support by:
Tracking language context per page: Store
SITEURLandDEFAULT_LANGfrom each page's context duringqueue_page(), preserving the language-specific settings from each i18n_subsites runSlug-based translation grouping: Group articles/pages by their slug across all languages. Since the same content in different languages shares the same slug, this correctly links translations even when
i18n_subsitesprocesses them separatelyFull URL generation: Build absolute URLs using each page's own
SITEURL, with proper normalization of../path segments usingposixpath.normpathDual translation mechanism: Support both:
i18n_subsites)obj.translations(for standard multi-language setups)Changes
XML_URLandXML_TRANSLATIONtemplates to use full URLsget_full_url()helper with URL path normalizationadd_to_url_map()to build URL map with slug trackinglink_translations()to merge translations from both mechanismsformat_hreflang()to generate hreflang XML linkscurrent_langandcurrent_siteurlper queued pageExample output
Before (missing hreflang):
After (proper bidirectional hreflang):