Skip to content

Commit

Permalink
Add og:image:alt and twitter:image:alt (#438)
Browse files Browse the repository at this point in the history
Merge pull request 438
  • Loading branch information
tordans committed Nov 22, 2021
1 parent 41b2393 commit 4a590c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ For most users, setting `image: [path-to-image]` on a per-page basis should be e
* `path` - The relative path to the image. Same as `image: [path-to-image]`
* `height` - The height of the Open Graph (`og:image`) image
* `width` - The width of the Open Graph (`og:image`) image
* `alt` - The alternative image text for Open Graph (`og:image:alt`) and Twitter (`twitter:image:alt`)

You can use any of the above, optional properties, like so:

Expand All @@ -106,6 +107,7 @@ image:
path: /img/twitter.png
height: 100
width: 100
alt: Twitter Logo
```

### Setting a default image
Expand Down Expand Up @@ -158,7 +160,7 @@ Which will generate following canonical_url:
You can override the default title modifier for paginated pages from `Page %{current} of %{total} for ` to a string of your
choice by setting a `seo_paginator_message` key in your `_config.yml`.

For example:
For example:

```yml
seo_paginator_message: "%<current>s / %<total>s | "
Expand Down
7 changes: 7 additions & 0 deletions lib/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
{% if seo_tag.image.width %}
<meta property="og:image:width" content="{{ seo_tag.image.width }}" />
{% endif %}
{% if seo_tag.image.alt %}
<meta property="og:image:alt" content="{{ seo_tag.image.alt }}" />
{% endif %}
{% endif %}

{% if page.date %}
Expand All @@ -61,6 +64,10 @@
<meta name="twitter:card" content="summary" />
{% endif %}

{% if seo_tag.image.alt %}
<meta name="twitter:image:alt" content="{{ seo_tag.image.alt }}" />
{% endif %}

{% if seo_tag.page_title %}
<meta property="twitter:title" content="{{ seo_tag.page_title }}" />
{% endif %}
Expand Down

0 comments on commit 4a590c9

Please sign in to comment.