Once you have written and published an article, it’s very likely that you will want to share it on social media or send to your friends on a messaging app.
One method to make the link more “attractive” is to include a cover image that will be shown in the link preview.
How do you set a cover image? You need to use a particular Open Graph tag named og:image
.
Open Graph
Open Graph is a protocol created by Facebook Meta to facilitate sharing articles and web pages on social media.
The syntax is very simple and all you have to do is to include a few meta tags in the header of your web page.
The most common tags to include are these ones:
og:title
is used as the main title of the page. It’s usually the biggest text being renderedog:description
is the additional text shown below the titleog:image
this is probably the most important tag to set, because it takes the biggest space wherever it’s being rendered
Pelican
Depending on the template you use, your Pelican based website may already support the og:image
tag.
For example in my case I need to add the Cover
attribute to my page meta tags, like I did for this article:
|
|
The template has a sub template (in my case it’s located here) may have something like this to render the image:
|
|
Note: if you don’t specify a Cover, the template will use your SITELOGO
image.
If your template doesn’t have something like this, you may have to use one of the following plugins. For the specific instructions about how to use them, please refer to their readme on GitHub.
pelican-seo plugin
pelican-seo is a useful addition to your Pelican based website, even if your template already supports cover images, because it automatically adds all the Open Graph tags, which are useful to boost the SEO of your website.
featured-image plugin
featured-image is a much simpler plugin. All it does is to check if an image has already been included in the meta tags. If it’s not present, it tries to get the first one found in the page.
Conclusion
Adding a cover image to your blog posts may seem a small thing, but it can make a huge difference if you decide to share your articles on social media.