add support for twitter cards (sharing on Twitter will be better); fixes #70

This commit is contained in:
Dean Attali 2016-07-20 15:00:09 -07:00
parent eb21409f4f
commit abf1334585
2 changed files with 16 additions and 5 deletions

View File

@ -122,7 +122,7 @@ subtitle | Short description of page or blog post that goes under the title
bigimg | Include a large full-width image at the top of the page. You can either give the path to a single image, or provide a list of images to cycle through (see [my personal website](http://deanattali.com/) as an example).
comments | If you want do add Disqus comments to a specific page, use `comments: true`. Comments are automatically enabled on blog posts; to turn comments off for a specific post, use `comments: false`. Comments only work if you set your Disqus id in the `_config.yml` file.
show-avatar | If you have an avatar configured in the `_config.yml` but you want to turn it off on a specific page, use `show-avatar: false`. If you want to turn it off by default, locate the line `show-avatar: true` in the file `_config.yml` and change the `true` to `false`; then you can selectively turn it on in specific pages using `show-avatar: true`.
fb-img | If you want to share a page on Facebook, by default Facebook will use the first image it can find on the page. If you want to specify an image to use when sharing the page on Facebook, then provide the image's URL here
share-img | If you want to specify an image to use when sharing the page on Facebook or Twitter, then provide the image's full URL here.
layout | What type of page this is (default is `blog` for blog posts and `page` for other pages. You can use `minimal` if you don't want a header and footer)
js | List of local JavaScript files to include in the page (eg. `/js/mypage.js`)
ext-js | List of external JavaScript files to include in the page (eg. `//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js`)

View File

@ -52,19 +52,30 @@
<!-- Facebook OpenGraph tags -->
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" />
<meta property="og:type" content="website" />
{% if page.id %}
<meta property="og:url" content="{{ site.url }}{{ page.url }}/" />
{% else %}
<meta property="og:url" content="{{ site.url }}{{ page.url | remove: '/index.html' | remove: '.html' }}" />
{% endif %}
{% if page.fb-img %}
<meta property="og:image" content="{{ page.fb-img }}" />
{% if page.share-img %}
<meta property="og:image" content="{{ page.share-img }}" />
{% elsif site.avatar %}
<meta property="og:image" content="{{ site.url }}{{ site.avatar }}" />
{% else %}
<meta property="og:image" content="" />
{% endif %}
<!-- Twitter summary cards -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@{{ site.author.twitter }}" />
<meta name="twitter:creator" content="@{{ site.author.twitter }}" />
<meta name="twitter:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" />
<meta name="twitter:description" content="{{ page.content | strip_html | xml_escape | truncatewords: 50 }}" />
<meta name="twitter:image" content="https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg" />
{% if page.share-img %}
<meta name="twitter:image" content="{{ page.share-img }}" />
{% elsif site.avatar %}
<meta name="twitter:image" content="{{ site.url }}{{ site.avatar }}" />
{% endif %}
</head>