Skip to content

Commit

Permalink
Alternate links
Browse files Browse the repository at this point in the history
  • Loading branch information
falkodev committed Dec 6, 2024
1 parent a9118f6 commit 5de2bcf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
{% block locale %}{{ data.locale }}{% endblock %}

{% block startHead %}
{% set slug = '/' %}
{% for localization in data.localizations %}
{% if localization.aposLocale == 'en:published' %}
<link rel="canonical" href="{{ data.baseUrlWithPrefix }}/en{{ localization.slug }}" />
{% set slug = localization.slug %}
{% endif %}

{% if localization.current %}
{% if localization.aposLocale == 'en:published' %}
<link rel="canonical" href="{{ data.page._url }}" />
{% else %}
<link rel="alternate" href="{{ data.baseUrlWithPrefix }}/en{{ slug }}" hreflang="{{ localization.aposLocale.split(':')[0] }}" />
{% endif %}
{% endif %}
{% endfor %}
{% endblock %}
Expand Down

0 comments on commit 5de2bcf

Please sign in to comment.