Skip to content

Commit

Permalink
feat(template): better Twitter Cards and Open Graph support
Browse files Browse the repository at this point in the history
  • Loading branch information
sparanoid committed Nov 28, 2016
1 parent 8cb6e54 commit fec052b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
11 changes: 11 additions & 0 deletions _app/_includes/_amsf.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@
{% endif %}
{% endcapture %}

{% comment %}
Page type (used by Twitter Cards)
{% endcomment %}
{% capture amsf_page_type_twitter %}
{% if site.tc_large_image or page.tc_large_image %}
summary_large_image
{% else %}
summary
{% endif %}
{% endcapture %}

{% comment %}
Page language tag
{% endcomment %}
Expand Down
22 changes: 9 additions & 13 deletions _app/_includes/themes/curtana/includes/open-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
<meta property="og:description" content="{{ amsf_site_desc | strip }}">
<meta property="og:image" content="{{ amsf_page_thumb | strip }}">

<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="{{ amsf_page_title }}">
<meta name="twitter:url" content="{{ amsf_page_url }}">
<meta name="twitter:description" content="{{ amsf_site_desc | strip }}">
<meta name="twitter:image" content="{{ amsf_page_thumb | strip }}">
<meta name="twitter:card" content="{{ amsf_page_type_twitter | strip }}">

{% if site.twitter %}
<meta name="twitter:site" content="@{{ site.twitter }}">
{% endif %}

{% if author.twitter %}
<meta name="twitter:creator" content="@{{ author.twitter }}">
{% endif %}

{% if page.path contains "_posts" %}
<meta property="article:published_time" content="{{ amsf_page_pubdate | date_to_xmlschema }}">
Expand All @@ -23,11 +27,3 @@
<meta name="twitter:label2" value="Reading time">
<meta name="twitter:data2" value="{{ amsf_page_reading_time | strip }}">
{% endif %}

{% if site.twitter %}
<meta name="twitter:site" content="@{{ site.twitter }}">
{% endif %}

{% if author.twitter %}
<meta name="twitter:creator" content="@{{ author.twitter }}">
{% endif %}
10 changes: 7 additions & 3 deletions _config.init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ url: https://sparanoid.com
# Media assets URL used in posts, without trailing slash. ie.
# `<img src="{{ site.file }}/image.png">`. In the most cases this URL should be
# powered by a CDN provider
file: //d349cztnlupsuf.cloudfront.net
file: https://d349cztnlupsuf.cloudfront.net

# Download files URL used in posts, ie. href="{{ site.download }}/package.zip",
# this should also be a CDN link just like `site.file`. There're no notable
# differences in `site.file` and `site.download`, I just use the one for post
# images and the other for large download files. That's it. Remove or ignore
# this if you don't need it.
download: //d1bmx7s6749k4k.cloudfront.net
download: https://d1bmx7s6749k4k.cloudfront.net

# Google Analytics tracking code
google_analytics:
Expand All @@ -119,6 +119,10 @@ google_analytics:
# Site Twitter account handle
twitter: sparanoid

# Use summary card with large image for Twitter Cards, require theme support
# Default: false
tc_large_image: false

# Force UTF-8 encoding, enable this will simply add <meta charset="utf-8"> to
# the head of your pages
# Default: false
Expand All @@ -133,7 +137,7 @@ link_blog: false
# Default: false
rss_excerpt: false

# Show generator credits
# Show or hide generator credits, require theme support
# Default: true
credits: true

Expand Down
10 changes: 7 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ url: https://sparanoid.com
# Media assets URL used in posts, without trailing slash. ie.
# `<img src="{{ site.file }}/image.png">`. In the most cases this URL should be
# powered by a CDN provider
file: //d349cztnlupsuf.cloudfront.net
file: https://d349cztnlupsuf.cloudfront.net

# Download files URL used in posts, ie. href="{{ site.download }}/package.zip",
# this should also be a CDN link just like `site.file`. There're no notable
# differences in `site.file` and `site.download`, I just use the one for post
# images and the other for large download files. That's it. Remove or ignore
# this if you don't need it.
download: //d1bmx7s6749k4k.cloudfront.net
download: https://d1bmx7s6749k4k.cloudfront.net

# Google Analytics tracking code
google_analytics:
Expand All @@ -119,6 +119,10 @@ google_analytics:
# Site Twitter account handle
twitter: sparanoid

# Use summary card with large image for Twitter Cards, require theme support
# Default: false
tc_large_image: false

# Force UTF-8 encoding, enable this will simply add <meta charset="utf-8"> to
# the head of your pages
# Default: false
Expand All @@ -133,7 +137,7 @@ link_blog: false
# Default: false
rss_excerpt: false

# Show generator credits
# Show or hide generator credits, require theme support
# Default: true
credits: true

Expand Down

0 comments on commit fec052b

Please sign in to comment.