mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Generate mobile bi-directional links
We have canonical links that point to the desktop site from mobile, but Google
would really like us to point the other way, too - to mobile from desktop.
They call these "bi-directional annotations". More on that here:
https://developers.google.com/webmasters/mobile-sites/mobile-seo/configurations/separate-urls?hl=en
This commit is contained in:
committed by
Jordan Milne
parent
689a9554e6
commit
920abafaa6
@@ -272,6 +272,10 @@ class Reddit(Templated):
|
||||
if g.domain_prefix:
|
||||
u.hostname = "%s.%s" % (g.domain_prefix, u.hostname)
|
||||
self.canonical_link = u.unparse()
|
||||
# Generate a mobile link for Google.
|
||||
u = UrlParser(request.fullpath)
|
||||
u.hostname = 'i.%s' % g.domain
|
||||
self.mobile_link = u.unparse()
|
||||
|
||||
if self.show_infobar:
|
||||
if not infotext:
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
<meta name="description" content="${getattr(thing, 'short_description', None) or g.short_description}" />
|
||||
<meta name="referrer" content="${c.referrer_policy}">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
%if hasattr(thing, 'mobile_link'):
|
||||
<link rel="alternate" media="only screen and (max-width: 640px)" href="${thing.mobile_link}" />
|
||||
%endif
|
||||
${self.viewport()}
|
||||
${self.robots()}
|
||||
${self.pagemeta()}
|
||||
|
||||
Reference in New Issue
Block a user