|
49 | 49 | {% endunless %} |
50 | 50 | {% endif %} |
51 | 51 |
|
| 52 | +{% if page.description %} |
| 53 | + {% assign meta_description = page.description | strip_html | strip_newlines | normalize_whitespace %} |
| 54 | +{% elsif page.excerpt %} |
| 55 | + {% assign meta_description = page.excerpt | strip_html | strip_newlines | normalize_whitespace %} |
| 56 | +{% else %} |
| 57 | + {% assign meta_description = site.description | strip_html | strip_newlines | normalize_whitespace %} |
| 58 | +{% endif %} |
| 59 | + |
| 60 | +{% if page.og_image %} |
| 61 | + {% assign social_image = page.og_image | absolute_url %} |
| 62 | +{% elsif site.og_image %} |
| 63 | + {% assign social_image = site.og_image | absolute_url %} |
| 64 | +{% endif %} |
| 65 | + |
| 66 | +{% if page.title and page.url != '/' %} |
| 67 | + {% capture social_title %}{{ page.title }} | {{ title }}{% endcapture %} |
| 68 | +{% else %} |
| 69 | + {% assign social_title = title %} |
| 70 | +{% endif %} |
| 71 | + |
52 | 72 | {% if site.serve_og_meta %} |
53 | 73 | <!-- OpenGraph --> |
54 | | - <meta property="og:site_name" content="{{ title }}"> |
| 74 | + <meta property="og:site_name" content="{{ site.title }}"> |
55 | 75 | <meta property="og:type" content="{% if is_blog_post %}article{% else %}website{% endif %}"> |
56 | | - <meta property="og:title" content="{% if page.title %}{{ title }} | {{ page.title }}{% else %}{{ title }}{% endif %}"> |
| 76 | + <meta property="og:title" content="{{ social_title }}"> |
57 | 77 | <meta property="og:url" content="{{ page.url | prepend: site.baseurl | prepend: site.url | remove_first: 'index.html' }}"> |
58 | | - <meta property="og:description" content="{% if page.description %}{{ page.description }}{% else %}{{ site.description }}{% endif %}"> |
59 | | - {% if page.og_image or site.og_image %} |
60 | | - <meta property="og:image" content="{% if page.og_image %}{{ page.og_image }}{% else %}{{ site.og_image }}{% endif %}"> |
| 78 | + <meta property="og:description" content="{{ meta_description }}"> |
| 79 | + {% if social_image %} |
| 80 | + <meta property="og:image" content="{{ social_image }}"> |
61 | 81 | {% endif %} |
62 | 82 | <meta property="og:locale" content="{{ site.lang }}"> |
63 | 83 |
|
64 | 84 | <!-- Twitter card --> |
65 | | - <meta name="twitter:card" content="summary"> |
66 | | - <meta name="twitter:title" content="{% if page.title %}{{ page.title }}{% else %}{{ title }}{% endif %}"> |
67 | | - <meta name="twitter:description" content="{% if page.description %}{{ page.description }}{% else %}{{ site.description }}{% endif %}"> |
68 | | - {% if page.og_image or site.og_image %} |
69 | | - <meta name="twitter:image" content="{% if page.og_image %}{{ page.og_image }}{% else %}{{ site.og_image }}{% endif %}"> |
| 85 | + <meta name="twitter:card" content="{% if social_image %}summary_large_image{% else %}summary{% endif %}"> |
| 86 | + <meta name="twitter:title" content="{{ social_title }}"> |
| 87 | + <meta name="twitter:description" content="{{ meta_description }}"> |
| 88 | + {% if social_image %} |
| 89 | + <meta name="twitter:image" content="{{ social_image }}"> |
70 | 90 | {% endif %} |
71 | 91 | {% if site.x_username %} |
72 | 92 | <meta name="twitter:site" content="@{{ site.x_username }}"> |
|
0 commit comments