How to include all language URLs in Sitemap? #392
Unanswered
enzedonline
asked this question in
Q&A
Replies: 2 comments 1 reply
|
I added a custom get_sitemap_urls to the home page model - does the job but maybe there is a better way to include other locales? This way makes a few presumptions about your site layout: |
1 reply
|
I use a custom Sitemap class for generating sitemaps in multilingual sites from wagtail.contrib.sitemaps import Sitemap
class CustomSitemap(Sitemap):
def items(self):
root_page = self.get_wagtail_site().root_page
items = (
root_page.get_descendants(inclusive=True).live().public().order_by("path").defer_streamfields().specific()
)
root_translations = root_page.get_translations()
for translation in root_translations:
# gets also any other translated pages that exist in other languages, but not under the root page
translation_items = (
translation.get_descendants(inclusive=False)
.live()
.public()
.order_by("path")
.defer_streamfields()
.specific()
.exclude(translation_key__in=items.values_list("translation_key", flat=True))
)
items |= translation_items
return itemsand in |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Using the contrib.sitemaps, it seems to only generate sitemap for the default language.
Is there a way to get it to index the other locales as well?
All reactions