sigal
sigal copied to clipboard
Twitter Cards for Albums / Images
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,
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.
Would be great to add this to sigal's themes :)
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)
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