Render og:locale meta only when defined explicitly (#388)

Merge pull request 388
This commit is contained in:
Ashwin Maroli 2020-10-08 20:12:00 +05:30 committed by GitHub
parent dac459f6f9
commit 54beeaaaf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -66,7 +66,8 @@ The following properties are available:
yandex: 1234
baidu: 1234
```
* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`.
* `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. Takes priority
over existing config key `lang`.
The SEO tag will respect the following YAML front matter if included in a post, page, or document:
@ -74,6 +75,6 @@ The SEO tag will respect the following YAML front matter if included in a post,
* `description` - A short description of the page's content
* `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`)
* `author` - Page-, post-, or document-specific author information (see [Advanced usage](advanced-usage.md#author-information))
* `lang` - Page-, post-, or document-specific language information
* `locale` - Page-, post-, or document-specific locale information. Takes priority over existing front matter attribute `lang`.
*Note:* Front matter defaults can be used for any of the above values as described in advanced usage with an image example.

View File

@ -164,6 +164,10 @@ module Jekyll
@page_lang ||= page["lang"] || site["lang"] || "en_US"
end
def page_locale
@page_locale ||= (page["locale"] || site["locale"] || page_lang).tr("-", "_")
end
def canonical_url
@canonical_url ||= begin
if page["canonical_url"].to_s.empty?

View File

@ -13,7 +13,7 @@
<meta name="author" content="{{ seo_tag.author.name }}" />
{% endif %}
<meta property="og:locale" content="{{ seo_tag.page_lang | replace:'-','_' }}" />
<meta property="og:locale" content="{{ seo_tag.page_locale }}" />
{% if seo_tag.description %}
<meta name="description" content="{{ seo_tag.description }}" />