Skip to content

Instantly share code, notes, and snippets.

@jbrooksuk
Created January 5, 2013 19:03
Show Gist options
  • Save jbrooksuk/4463111 to your computer and use it in GitHub Desktop.
Save jbrooksuk/4463111 to your computer and use it in GitHub Desktop.
Open graph tags used in my Octopress blog.
<!-- Rich Object stuff -->
<meta property="og:url" value="{{ site.url }}{{ page.url }}">
<meta property="og:type" content="website" />
{% if page.title %}<meta property="og:title" value="{% if page.title %}{{ page.title }}{% endif %}">
<meta property="og:description" value="{% if page.description %}{{ page.description }}{% else %}{{site.description}}{% endif %}">
{% else %}<meta property="og:title" value="{{ site.title }}">
<meta property="og:description" value="{{ description }}">
{% endif %}{% if page.cover %}<meta property="og:image" value="{{ site.url }}{{ page.cover }}">{% endif %}
@egid
Copy link

egid commented Apr 7, 2013

Line 7 is throwing the entire contents of my page into the og:description tag - my fix has it like so:

<meta property="og:description" value="{{ site.description }}">

@sandipb
Copy link

sandipb commented Jul 12, 2013

hi egid,
if you are using the default octopress theme, then you should be using:

<meta property="og:description" value="{{ description | strip_html | condense_spaces | truncate:150 }}">

@sandipb
Copy link

sandipb commented Jul 12, 2013

if using default theme, some of those blocks in the gist can be used simply like this (copied from elsewhere in the same file). Add this to the bottom of head.html:

<meta property="og:title" value="{% if page.title %}{{ page.title }} - {% endif %}{{ site.title }}" />
<meta property="og:description" value="{{ description | strip_html | condense_spaces | truncate:150 }}" />
<meta property="og:url" value="{{ site.url }}{{ page.url }}" />                    
<meta property="og:type" content="website" />                                    
{% if page.cover %}<meta property="og:image" value="{{ site.url }}{{ page.cover }}" />{% endif %}  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment