Blog Open Graph Support
Just like regular posts on Ruby Static Pro, blog posts support Open Graph Protocol (OGP) tags as well and can be override in the same way that the default posts can be overridden too.
Default Open Graph Support in Blog Posts
By default, the following will be used for Open Graph support. Please see the config.rb file and the social_tags() method for more details.
Example frontmatter for a blog post:
---
# Title and summary are used for OGP meta tags
title: "The Title That Will Be the OGP Title"
summary: "This is the summary that will show up as the description in OGP tags"
date: 2024-09-15 11:02 UTC
type: blog
tags: startups,coding
author: brianbaiker
featured_image: this_image_will_be_used_as_the_ogp_image.jpg
og_image:
# Use the following to override the default ogp settings (which is title and summary and featured_image)
ogp:
title:
description:
image_path:
---
The title and summary will be used for the following open graph tags:
The title blog frontmatter will provide OGP values to:
og:titletwitter:title
The summary blog frontmatter will provide OGP values to:
og:descriptiontwitter:description
The featured_image blog frontmater will provide OGP values to:
og:imageog:image:secure_urltwitter:image
Overriding Default OGP Values
You can see a sample of this in this blog post and it’s respective OGP results.
Notice how the featured image is different than the OGP preview. This is because the featured image is set to the image you see on the site, but the ogp, image_path has its value set to another image which will only be visible in anythign requesting/reading the OGP tags (social media, link preview in chats, etc)
How To Override The Values
To override the default OGP values, you can specify an ogp structure in the frontmatter (as shown above, repeated here for simplicity):
ogp:
title:
description:
image_path:
All of these values, title, description, and image_path are all optional. Including any of them will override the corresponding ogp tag.
titlewill override the blog titledescriptionwill override the summary from the blogimage_pathwill override thefeatured_image
If you only want to override the image_path, then just provide that value. If you want to override the description then provide that only. You can provide on or all. They are all optional. Ruby Static Pro will look for each key, and if it is present, it will override the OGP tag for that value.
### Why would you want to override values?
You may want to override default values because you have a better image, title and/or description to showcase the blog post in OGP previews. This is compeltely up to you. If you leave out the ogp data structure in the frontmatter, the default values will be provided as mentioned above.