Opened 3 years ago
Closed 3 years ago
#33418 closed Uncategorized (invalid)
Alternates does not use langcodes in alternate urls
Reported by: | U-Eike | Owned by: | ravi kunwar |
---|---|---|---|
Component: | contrib.sitemaps | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Carlton Gibson, Florian Demmer | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As said in the title when using the sitemap creator and alternates all alternate urls are identical to the location url
Example
loc = f'{protocol}://{domain}{self._location(item)}' = https://django/test
and
alternate = f'{protocol}://{domain}/{self._location(item, lang_code)}' = https://django/test
This means that the base url and the internationally pointing url are the same thing and unless you have automatic language redirection a search engine will server users in another country the same base page
An adjustment I made which solved this problem for me is this
alternate = f'{protocol}://{domain}/{lang_code}{self._location(item, lang_code)}' = https://django/en/test
That causes all alternate urls to be generated with the required lang codes included in the urls and allows the sitemap to contain all variants of the website
meaning the search engine will now server users in the appropriate location with the right page variant without requiring automatic redirection
This adjustment is only in line 188 of the sitemap initialization file
the x-default stays the same but options could be added to make it a certain lang code
Attachments (1)
Change History (3)
by , 3 years ago
Attachment: | __init__.py added |
---|
comment:1 by , 3 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 3 years ago
Cc: | added |
---|---|
Component: | Internationalization → contrib.sitemaps |
Easy pickings: | unset |
Has patch: | unset |
Resolution: | → invalid |
Status: | assigned → closed |
As far as I'm aware alternates
contain language codes, see tests added in 16218c20606d8cd89c5393970c83da04598a3e04. Maybe you have i18n
disabled.
Adjustment made to sitemap initializer