Skip to content

Commit

Permalink
Open Graph Tags Incomplete
Browse files Browse the repository at this point in the history
Some SEO tools, like Ahrefs, are flagging the OG tags as incomplete, which is correct based on https://ogp.me/. We are fixing the issue by adding '/'.
  • Loading branch information
vitali-karmanov authored Aug 12, 2024
1 parent d06c1b0 commit f43406f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/Piranha.AspNetCore/Extensions/PiranhaHtmlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ public static HtmlString MetaTags(this IApplicationService app, IMeta content, b
// Generate open graph tags
if (content is PageBase page && page.IsStartPage)
{
sb.AppendLine($"<meta property=\"og:type\" content=\"website\">");
sb.AppendLine($"<meta property=\"og:type\" content=\"website\"/>");
}
else
{
sb.AppendLine($"<meta property=\"og:type\" content=\"article\">");
sb.AppendLine($"<meta property=\"og:type\" content=\"article\"/>");
}
sb.AppendLine($"<meta property=\"og:title\" content=\"{ OgTitle(content) }\">");
sb.AppendLine($"<meta property=\"og:title\" content=\"{ OgTitle(content) }\"/>");
if (content.OgImage != null && content.OgImage.HasValue)
{
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(content.OgImage) }\">");
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(content.OgImage) }\"/>");
}
else if (content is RoutedContentBase contentBase && contentBase.PrimaryImage != null && contentBase.PrimaryImage.HasValue)
{
// If there's no OG image specified but we have a primary image,
// default to the primary image.
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(contentBase.PrimaryImage) }\">");
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(contentBase.PrimaryImage) }\"/>");
}
if (!string.IsNullOrWhiteSpace(OgDescription(content)))
{
sb.AppendLine($"<meta property=\"og:description\" content=\"{ OgDescription(content) }\">");
sb.AppendLine($"<meta property=\"og:description\" content=\"{ OgDescription(content) }\"/>");
}
}
return new HtmlString(sb.ToString());
Expand Down

0 comments on commit f43406f

Please sign in to comment.