If you have installed the jekyll-polyglot gem, these additions to your site head can easily provide your jekyll blog with Google-powered SEO bonuses.
Per the WHATWG HTML Living Standard, you should declare the page language using the lang attribute on the root HTML element. Add this to your layout:
<html lang="{{ site.active_lang }}">This enables browsers, search engines, and assistive technologies (screen readers, translation tools) to correctly process your content.
You can easily add hreflang="fr" alternate tags to your site, achieving SEO with google multi-language searches. Fallback to the default language version of your site when the browser uses an unmatched language with hreflang="x-default"
Be sure to include canonical tags when identifying content on similar pages of the same language.
Add the following to your head:
{% if page.lang == site.default_lang %}
<link rel="canonical"
href="http://yoursite.com{{page.permalink}}" />
{% else %}
<link rel="canonical"
href="http://yoursite.com/{{page.lang}}{{page.permalink}}" />
{% endif %}
<link rel="alternate"
hreflang="{{site.default_lang}}"
href="http://yoursite.com{{page.permalink}}" />
<link rel="alternate"
hreflang="x-default"
href="http://yoursite.com{{page.permalink}}" />
{% for lang in site.languages %}
{% if lang == site.default_lang %}
{% continue %}
{% endif %}
<link rel="alternate"
hreflang="{{lang}}"
href="http://yoursite.com/{{lang}}{{page.permalink}}" />
{% endfor %}You can get the canonical link, alternate hreflang links, and x-default fallback with a single tag added to your head.html:
{% I18n_Headers %}Note: You should still add <html lang="fr"> to your layout’s root element separately, as described above.
With this SEO, each page click for one site’s language will count towards the net clicks of all languages on the website.
jekyll-seo-tag is a another jekyll plugin that emits <title>, <meta> tags for SEO. Polyglot’s {% I18n_Headers %} is designed to live alongside it: let jekyll-seo-tag handle everything except the canonical URL, and let polyglot handle the canonical and hreflang alternates (which it can do correctly across languages):
{% seo canonical=false %}
{% I18n_Headers %}The canonical=false option requires jekyll-seo-tag v2.9.0 or later.
By default, a page that has no translation in the active language still gets a canonical pointing at its translated URL. For better SEO, you can have fallback pages point their canonical URL at the default language version instead. Add to your _config.yml:
fallback_canonical_to_default_lang: trueWith this enabled:
/es/sobre-nosotros/)./about/ instead of /es/about/).This consolidates SEO authority on the original content and prevents search engines from indexing duplicate fallback pages across languages.
The jekyll-redirect-from plugin lets pages declare old URLs they should redirect from. Polyglot integrates with it in two ways:
Automatic cross-language redirects via page_id. When two pages share a page_id but have different permalinks, polyglot will automatically add the other-language permalinks to the page’s redirect_from. No manual configuration needed — just make sure both pages have the same page_id in their front matter.
Language-scoped redirect_from. When a page in a non-default language declares its own redirect_from, polyglot automatically prefixes the paths with the page’s language code, so /old-path becomes /fr/old-path on a French page. Paths that already start with the language code are left alone.
Include a customized redirect.html layout with the site.
New in 1.13.0.
When you deploy to Netlify with a _redirects file, Polyglot can automatically generate language-prefixed copies of each rule so they work on all of your localized URLs.
Enable it in _config.yml:
localize_redirects: true
exclude_from_redirect_localization:
- /signin
- /appWith this, a single rule like:
/github https://github.com/org/repo 302is expanded into language-prefixed copies for each configured language:
/github https://github.com/org/repo 302
/fr/github https://github.com/org/repo 302
/de/github https://github.com/org/repo 302
/sv/github https://github.com/org/repo 302External destination URLs are preserved as-is. Paths listed under exclude_from_redirect_localization are not localized, which is useful for authentication endpoints or single-page-app routes that should only exist at the root.