Skip to content

Commit b82680b

Browse files
authored
Allow overriding HTML lang on a per-page basis (#4862)
The W3C [recommends](https://www.w3.org/International/questions/qa-html-language-declarations) to specify language using identifiers as per [RFC 5646](https://tools.ietf.org/html/rfc5646) which uses dashes.
1 parent 7b6b450 commit b82680b

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

_includes/archive-single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% endif %}
1212

1313
<div class="{{ include.type | default: 'list' }}__item">
14-
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
14+
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork"{% if post.locale %} lang="{{ post.locale }}"{% endif %}>
1515
{% if include.type == "grid" and teaser %}
1616
<div class="archive__item-teaser">
1717
<img src="{{ teaser | relative_url }}" alt="">

_includes/breadcrumbs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<span class="sep">{{ site.data.ui-text[site.locale].breadcrumb_separator | default: "/" }}</span>
2727
{% endif %}
2828
{% if forloop.last %}
29-
<li class="current">{{ page.title }}</li>
29+
<li class="current"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>{{ page.title }}</li>
3030
{% else %}
3131
{% assign i = i | plus: 1 %}
3232
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">

_layouts/archive-taxonomy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<div class="archive">
2222
{% unless page.header.overlay_color or page.header.overlay_image %}
23-
<h1 id="page-title" class="page__title">{{ page.title }}</h1>
23+
<h1 id="page-title" class="page__title"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>{{ page.title }}</h1>
2424
{% endunless %}
2525
{% for post in page.posts %}
2626
{% include archive-single.html %}

_layouts/archive.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<div class="archive">
2121
{% unless page.header.overlay_color or page.header.overlay_image %}
22-
<h1 id="page-title" class="page__title">{{ page.title }}</h1>
22+
<h1 id="page-title" class="page__title"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>{{ page.title }}</h1>
2323
{% endunless %}
2424
{{ content }}
2525
</div>

_layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<!doctype html>
55
{% include copyright.html %}
6-
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
6+
<html lang="{{ site.locale | replace: "_", "-" | default: "en" }}" class="no-js">
77
<head>
88
{% include head.html %}
99
{% include head/custom.html %}

_layouts/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<div class="archive">
1919
{% unless page.header.overlay_color or page.header.overlay_image %}
20-
<h1 id="page-title" class="page__title">{{ page.title }}</h1>
20+
<h1 id="page-title" class="page__title"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>{{ page.title }}</h1>
2121
{% endunless %}
2222

2323
{{ content }}

_layouts/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div id="main" role="main">
2222
{% include sidebar.html %}
2323

24-
<article class="page" itemscope itemtype="https://schema.org/CreativeWork">
24+
<article class="page" itemscope itemtype="https://schema.org/CreativeWork"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>
2525
{% if page.title %}<meta itemprop="headline" content="{{ page.title | replace: '|', '&#124;' | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
2626
{% if page.excerpt %}<meta itemprop="description" content="{{ page.excerpt | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
2727
{% if page.date %}<meta itemprop="datePublished" content="{{ page.date | date_to_xmlschema }}">{% endif %}

_layouts/splash.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{% endif %}
1010

1111
<div id="main" role="main">
12-
<article class="splash" itemscope itemtype="https://schema.org/CreativeWork">
12+
<article class="splash" itemscope itemtype="https://schema.org/CreativeWork"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>
1313
{% if page.title %}<meta itemprop="headline" content="{{ page.title | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
1414
{% if page.excerpt %}<meta itemprop="description" content="{{ page.excerpt | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
1515
{% if page.date %}<meta itemprop="datePublished" content="{{ page.date | date_to_xmlschema }}">{% endif %}

0 commit comments

Comments
 (0)