Skip to content

Commit

Permalink
Merge pull request #394 from creativecommons/hreflang
Browse files Browse the repository at this point in the history
App: Add `hreflang` links
  • Loading branch information
TimidRobot authored Nov 22, 2023
2 parents 96a3c1d + 3f6984b commit 6d1e833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions legal_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def view_list(request, category, language_code=None):
"category": category,
"category_title": category_title,
"category_list": category_list,
"language_default": get_default_language_for_jurisdiction(None),
"languages_and_links": languages_and_links,
"list_licenses": list_licenses,
"list_publicdomain": list_publicdomain,
Expand Down Expand Up @@ -538,6 +539,7 @@ def view_deed(
"category": category,
"category_title": category_title,
"identifier": tool.identifier(),
"language_default": language_default,
"languages_and_links": languages_and_links,
"legal_code_rel_path": legal_code_rel_path,
"list_licenses": list_licenses,
Expand Down Expand Up @@ -649,6 +651,7 @@ def view_legal_code(
"category_title": category_title,
"deed_rel_path": deed_rel_path,
"identifier": tool.identifier(),
"language_default": language_default,
"languages_and_links": languages_and_links,
"legal_code": legal_code,
"list_licenses": list_licenses,
Expand Down
12 changes: 12 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>{% block title %}{% endblock %} | Creative Commons</title>
<link href="{{ canonical_url_html }}" rel="canonical"/>
{% for option in languages_and_links %}
{% if option.cc_language_code == language_default %}
<!-- Default: {{ option.name_local }} -->
<link href="{{ option.link }}" hreflang="x-default" rel="alternate" />
{% endif %}
{% endfor %}
{% for option in languages_and_links %}
{% if not option.selected %}
<!-- {{ option.name_local }} -->
<link href="{{ option.link }}" hreflang="{{ option.cc_language_code }}" rel="alternate" />
{% endif %}
{% endfor %}
{% block head_meta %}
{% endblock %}
<link rel="icon" href="/wp-content/themes/vocabulary-theme/vocabulary/favicon/favicon.ico" sizes="any">
Expand Down

0 comments on commit 6d1e833

Please sign in to comment.