sigal icon indicating copy to clipboard operation
sigal copied to clipboard

Twitter Cards for Albums / Images

Open mpbish opened this issue 5 years ago • 4 comments

Hello,

Would anyone be able to help me to set-up twitter cards for albums and images please (especially albums). It would be great to show some the album name, description and a thumbnail when sharing to twitter).

https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started

Many thanks,

mpbish avatar Jan 27 '20 16:01 mpbish

Hi @mpbish,

I have a custom theme with twitter / open graph cards for the albums. Be aware that I am assuming that you know how to create blocks and how jinja templates work.

{% block metadata %}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:creator" content=" [your twitter handle - field is not required ] " />

<meta property="og:title" content="{{ album.title }}" />
<meta property="og:type" content="website" />

<meta property="og:description" content="{{ album.meta.subtitle | join('') }}" />
<meta property="og:url" content="{{ album.url }}" />
<meta property="og:image" content="{{ album.thumbnail }}" />
{% endblock %}

For my albums I use an index.md file with two fields, Title and Subtitle.

devndive avatar Apr 20 '20 06:04 devndive

Would be great to add this to sigal's themes :)

saimn avatar Apr 23 '20 02:04 saimn

There's a small problem though. The album.url and album.thumbnail variables return a relative file path. It would be great to have some option to return a full path (with having a base_url variable for example)

isti03 avatar Oct 19 '20 18:10 isti03

It would be great to have some option to return a full path (with having a base_url variable for example)

You could use urllib.parse.urljoin since urllib is already in use https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin

isti03 avatar Oct 21 '20 17:10 isti03