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

Add canonical links for Google #988

Draft
wants to merge 15 commits into
base: release
Choose a base branch
from
13 changes: 8 additions & 5 deletions _includes/general/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
{% for item in site.data.navigation.nav %}
{% if item.url %}
<li>
<h3><a href="{{ item.url | relative_url }}" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ item.title }}</a></h3>
{% if page.lang == site.default_lang %}{% capture lang_rel %}canonical{% endcapture %}{% else %}{% capture lang_rel %}alternate{% endcapture %}{% endif %}
<h3><a href="{{ item.url | relative_url }}" rel="{{ lang_rel }}" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ item.title }}</a></h3>
{% else %}
<li>
<h3>{{ item.title }}</h3>
{% endif %}
{% if item.subfolderitems[0] %}
<ul>
{% for entry in item.subfolderitems %}
<li><a href="{{ entry.url }}" class="{% if entry.url == page.url or entry.selectOnLayout == page.layout %}selected{% endif %}">{{ entry.page }}</a>
{% if page.lang == site.default_lang %}{% capture lang_rel %}canonical{% endcapture %}{% else %}{% capture lang_rel %}alternate{% endcapture %}{% endif %}
<li><a href="{{ entry.url }}" lang="{{ lang_rel }}" class="{% if entry.url == page.url or entry.selectOnLayout == page.layout %}selected{% endif %}">{{ entry.page }}</a>
{% if entry.subsubfolderitems[0] %}
<ul>
{% for subentry in entry.subsubfolderitems %}
<li><a href="{{ subentry.url }}" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ subentry.page }}</a></li>
{% for subentry in entry.subsubfolderitems %}
pljones marked this conversation as resolved.
Show resolved Hide resolved
{% if page.lang == site.default_lang %}{% capture lang_rel %}canonical{% endcapture %}{% else %}{% capture lang_rel %}alternate{% endcapture %}{% endif %}
pljones marked this conversation as resolved.
Show resolved Hide resolved
<li><a href="{{ subentry.url }}" lang="{{ lang_rel }}" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ subentry.page }}</a></li>
pljones marked this conversation as resolved.
Show resolved Hide resolved
{% endfor %}
</ul>
{% endif %}
Expand All @@ -30,6 +33,6 @@ <h3>{{ item.title }}</h3>
{% endfor %}
{% endif %}
</ul>
<div id="cc">{{ site.data.copyright.nav.docs }}</div>
<div id="cc">{{ site.data.copyright.nav.docs }}</div>
</nav>
</aside>
3 changes: 2 additions & 1 deletion _includes/headtags.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
{% for lng in site.languages %}
{% if lng == site.default_lang %}
{% capture langlink %}{{ site.a_rootpage }}{{ page.url }}{% endcapture %}
<link rel="canonical" hreflang="{{ lng }}" href="{{ langlink }}">
pljones marked this conversation as resolved.
Show resolved Hide resolved
{% else %}
{% capture langlink %}{{ site.a_rootpage }}/{{ lng }}{{ page.url }}{% endcapture %}
<link rel="alternate" hreflang="{{ lng }}" href="{{ langlink }}">
{% endif %}
<link rel="alternate" hreflang="{{ lng }}" href="{{ langlink }}">
{% endfor %}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/css/fox.min.css">
Expand Down
4 changes: 3 additions & 1 deletion _includes/langselect.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
{% else %}
{% if lng == site.default_lang %}
{% capture langlink %} {{ page.url }}{% endcapture %}
{% capture lang_rel %}canonical{% endcapture %}
{% else %}
{% capture langlink %}/{{ lng }}{{ page.url }}{% endcapture %}
{% capture lang_rel %}alternate{% endcapture %}
{% endif %}
gilgongo marked this conversation as resolved.
Show resolved Hide resolved
<li><a href="{{ langlink }}" data-slang="{{ lng }}">{{ lng }}</a></li>
gilgongo marked this conversation as resolved.
Show resolved Hide resolved
<li><a href="{{ langlink }}" rel="{{ lang_rel }}" data-slang="{{ lng }}">{{ lng }}</a></li>
pljones marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ category: hidden
{% for post in site.posts %}
{% unless post.published == false %}
<url>
<loc>{{ site.url }}{{ post.url }}</loc>
<loc>{{ site.a_rootpage }}{{ post.url }}</loc>
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
Expand Down
Loading