Opened 8 years ago

Last modified 4 years ago

#27395 closed New feature

Allow generating '<link rel="alternate ... hreflang=...>" for sitemaps' — at Version 5

Reported by: Hovi Owned by: nobody
Component: contrib.sitemaps Version: 1.10
Severity: Normal Keywords:
Cc: Hendy Irawan 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 (last modified by Hovi)

Hello,

django sitemap supports i18n field, that enables generating language-aware sitemaps, here is doc:
https://docs.djangoproject.com/en/1.10/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.i18n

Problem is, that it generates them just as each url separately with no relations. One of google recommendations is to mark same content in different languages using sitemap with xhtml:link element:
https://support.google.com/webmasters/answer/189077
https://support.google.com/webmasters/answer/2620865

Would be cool to add possibility to generate these tags.

Change History (6)

comment:1 by Tim Graham, 8 years ago

Is the idea to add something like a template tag that generates something like:

<link rel="alternate"
   hreflang="fr"
   href="https://docs.djangoproject.com/fr/1.10/ref/">
....
<link rel="alternate"
   hreflang="el"
   href="https://docs.djangoproject.com/el/1.10/ref/">
<link rel="alternate"
   hreflang="x-default"
   href="https://docs.djangoproject.com/en/1.10/ref/">
<link rel="alternate"
   hreflang="en"
   href="https://docs
.djangoproject.com/en/1.10/ref/">

for use on a webpage? (If so, I'm not familiar enough with sitemaps code to say whether or not it's feasible.) Or does this involve some change to the sitemap itself?

comment:2 by Hovi, 8 years ago

Both ways actually make sense (in html page and sitemap) and code generating it in both cases would be very similar, but to answer your original question - this involves changes to sitemap itself yes.

comment:3 by Tim Graham, 8 years ago

Summary: Django sitemap and i18nAllow generating '<link rel="alternate ... hreflang=...>" for sitemaps'
Triage Stage: UnreviewedAccepted

What are those changes? Are you able to offer a patch?

comment:4 by Hovi, 8 years ago

I included simple patch to demonstrate what would require changing, by no means it's supposed to be final. There may be a little more work to avoid duplicities, but it does pretty much everything necessary.

comment:5 by Hovi, 8 years ago

Description: modified (diff)

by Hovi, 8 years ago

Attachment: sitemap_hreflang.diff added

Path

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