#33662 closed New feature (fixed)
Choose which items are displayed per language in Sitemap
Reported by: | Roxane | Owned by: | Roxane |
---|---|---|---|
Component: | contrib.sitemaps | Version: | 4.0 |
Severity: | Normal | Keywords: | sitemap |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current implementation of Sitemap is : if we use i18n, then we display a cartesian product between some items and some languages.
There is no way to use the provided i18n automation if we want to display some items depending on the language (for instance non-translated blog articles).
I precise in my case, urls are translated, so given a language the url may not exist or raise an error.
Change History (11)
comment:1 by , 3 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 2 years ago
I would like to tackle this new feature, it sounds interesting. As Carlton Gibson said, could you expand please the description, so I can fully understand the idea of the new feature?.
For instance, on which scenario the URLs get translated? (Not sure, but this maybe sounds more like an error than a future).
It does sound as a new feature, being able to display some items depending on the language, by this do you mean like for example, only translate a menu or only translate what is inside a <div> or something similar?
Please expand your idea.
comment:3 by , 2 years ago
Component: | Uncategorized → contrib.sitemaps |
---|---|
Summary: | Choose witch items are to be display per language in Sitemap → Choose which items are displayed per language in Sitemap |
comment:4 by , 2 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Sorry for the delay, I did not at all see any of your comments sooner !
I have in my project a model Article which could be summed up in four fields (url_en, url_fr, content_en and content_fr). Some of these article are only written in one language. With no content, the page is empty. Even if it exists, I don't want this empty page to be in my sitemap.
My idea was to add a method in Sitemap to return a boolean indicating whether the item should be displayed in the sitemap given a language.
I made a first draft for a patch (https://github.com/django/django/compare/main...roxanebellot:django:ticket_33662). I wait for a green light on the feature before submitting it as a PR.
comment:5 by , 2 years ago
Has patch: | unset |
---|
@roxanebellot Please open a PR and add it here when you've done so. Thanks.
comment:7 by , 2 years ago
Patch needs improvement: | set |
---|
comment:8 by , 2 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
OK, sounds reasonable to at least look at.
Would you care to take on a patch? In either case could you perhaps expand the description to include a minimal reproduce setup so that someone picking it up had a few breadcrumbs to follow? Thanks!