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

Render og:locale meta only when defined explicitly #388

Merged
merged 7 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ 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:

* `title` - The title of the post, page, or document
* `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.
4 changes: 4 additions & 0 deletions lib/jekyll-seo-tag/drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def page_lang
@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?
Expand Down
2 changes: 1 addition & 1 deletion lib/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}" />
Expand Down