What is the best practice to add OGP tag?

10 views
Skip to first unread message

masafum...@gmail.com

unread,
Jun 23, 2020, 9:23:16 AM6/23/20
to nanoc
Hi, I wonder how to add OGP tag efficiently.
More specifically, og:url property should have the current url of the page, so I tried to use content_for helper to store the URL in each item.
However, the result is empty after fetching in in layout.
So what is the best way to add OGP tag with Nanoc?

Dave Everitt

unread,
Mar 4, 2021, 8:39:08 AM3/4/21
to nanoc
I use this kind of thing in my layouts for the Dublin Core metadata - specifically: if you add the domain before the "item.identifier" property you'll get the full URL.

<% if @item[:description] %><meta name="DC.Description" content="<%= @item[:description] %>"><% end %>
<% if @item[:keywords] %><meta name="DC.Subject" content="<%= @item[:keywords] %>"><% end %>
<meta name="DC.Identifier" content="<%= item.identifier %>">

Reply all
Reply to author
Forward
0 new messages