Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: Add hreflang links #394

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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