Opened 2 years ago

Closed 2 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)

__init__.py (8.1 KB ) - added by U-Eike 2 years ago.
Adjustment made to sitemap initializer

Download all attachments as: .zip

Change History (3)

by U-Eike, 2 years ago

Attachment: __init__.py added

Adjustment made to sitemap initializer

comment:1 by ravi kunwar, 2 years ago

Owner: changed from nobody to ravi kunwar
Status: newassigned

comment:2 by Mariusz Felisiak, 2 years ago

Cc: Carlton Gibson Florian Demmer added
Component: Internationalizationcontrib.sitemaps
Easy pickings: unset
Has patch: unset
Resolution: invalid
Status: assignedclosed

As far as I'm aware alternates contain language codes, see tests added in 16218c20606d8cd89c5393970c83da04598a3e04. Maybe you have i18n disabled.

Note: See TracTickets for help on using tickets.
Back to Top