Skip to content

Commit

Permalink
mod_seo: do not set home page to noindex on missing languages (0.x) (#…
Browse files Browse the repository at this point in the history
…3257)

* mod_seo: do not set home page to noindex on missing languages

* mod_translation: list all enabled languages as hreflang alternate URLs on the home page

* docs: fix version of alabaster
  • Loading branch information
mworrell committed Jan 13, 2023
1 parent 3e4a906 commit 50adf5f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
alabaster==0.7.12
sphinx-rtd-theme==0.2.4
Sphinx==1.5.3
jinja2<3.1.0
8 changes: 7 additions & 1 deletion modules/mod_seo/templates/_html_head_seo.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
{% block metadata %}
{% if m.config.seo.noindex.value or noindex %}
<meta name="robots" content="noindex,nofollow" />
{% elseif id and id.language and m.modules.active.mod_translation and not z_language|member:id.language %}
{% elseif zotonic_dispatch != `home`
and id
and id.page_path != '/'
and id.language
and m.modules.active.mod_translation
and not z_language|member:id.language
%}
{# Take one of the alternative urls, provided by mod_translation #}
<meta name="robots" content="noindex" />
{% else %}
Expand Down
5 changes: 5 additions & 0 deletions modules/mod_translation/templates/_html_head_translation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<link rel="alternate" hreflang="{{ code }}" href="{{ m.rsc[id].page_url_abs with z_language = code }}?page={{ q.page|escape }}" title="{{ m.rsc[id].title with z_language = code }}">
{% endfor %}{% endif %}
<link rel="alternate" hreflang="x-default" href="{{ m.rsc[id].page_url_abs with z_language = `x-default` }}?page={{ q.page|escape }}" title="{{ m.rsc[id].title with z_language = `x-default` }}">
{% elseif id and zotonic_dispatch == `home` and rewrite_url %}
{% for code,_ in m.translation.language_list_enabled %}
<link rel="alternate" hreflang="{{ code }}" href="{{ m.rsc[id].page_url_abs with z_language = code }}" title="{{ m.rsc[id].title with z_language = code }}">
{% endfor %}
<link rel="alternate" hreflang="x-default" href="{{ m.rsc[id].page_url_abs with z_language = `x-default` }}" title="{{ m.rsc[id].title with z_language = `x-default` }}">
{% elseif id and id.language %}
{% if rewrite_url %}{% for code in id.language %}
<link rel="alternate" hreflang="{{ code }}" href="{{ m.rsc[id].page_url_abs with z_language = code }}" title="{{ m.rsc[id].title with z_language = code }}">
Expand Down

0 comments on commit 50adf5f

Please sign in to comment.