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

Closed
wants to merge 15 commits into from
54 changes: 50 additions & 4 deletions _includes/general/nav.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
<aside id="gnav" class="fx-col-100-xs fx-col-25-m">
{% if page.hidelang %}{% else %}{% include langselect.html %}{% endif %}

<!--
Default lang is: {{ site.default_lang }}
Current lang is: {{ page.lang }}
-->
gilgongo marked this conversation as resolved.
Show resolved Hide resolved

{% if page.lng == site.default_lang %} {% comment %} Not sure why this isn't true for en. {% endcomment %}
gilgongo marked this conversation as resolved.
Show resolved Hide resolved

<nav id="mnv">
<ul>
{% if site.data.navigation.nav[0] %}
{% 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>
<h3><a href="{{ item.url | relative_url }}" rel="canonical" 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>
<li><a href="{{ entry.url }}" rel="canonical" 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>
<li><a href="{{ subentry.url }}" rel="canonical" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ subentry.page }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand All @@ -31,5 +39,43 @@ <h3>{{ item.title }}</h3>
{% endif %}
</ul>
<div id="cc">{{ site.data.copyright.nav.docs }}</div>
</nav>
</nav>

{% else %}

<nav id="mnv">
<ul>
{% if site.data.navigation.nav[0] %}
{% for item in site.data.navigation.nav %}
{% if item.url %}
<li>
<h3><a href="{{ item.url | relative_url }}" rel="alternate" 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 }}" rel="alternate" 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 }}" rel="alternate" class="{% if subentry.url == page.url or subentry.selectOnLayout == page.layout %}selected{% endif %}">{{ subentry.page }}</a></li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
<div id="cc">{{ site.data.copyright.nav.docs }}</div>
</nav>

{% endif %}

</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
3 changes: 2 additions & 1 deletion _includes/langselect.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
{% else %}
{% if lng == site.default_lang %}
{% capture langlink %} {{ page.url }}{% endcapture %}
<li><a href="{{ langlink }}" rel="canonical" hreflang="{{ lng }}" data-slang="{{ lng }}">{{ lng }}</a></li>
gilgongo marked this conversation as resolved.
Show resolved Hide resolved
{% else %}
{% capture langlink %}/{{ lng }}{{ page.url }}{% endcapture %}
<li><a href="{{ langlink }}" rel="alternate" hreflang="{{ lng }}" data-slang="{{ lng }}">{{ lng }}</a></li>
gilgongo marked this conversation as resolved.
Show resolved Hide resolved
{% 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
{% 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