Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Issues with "og:description" tag on pages that don't have summaries?

Started by Muut Archive 10 years ago · 3 replies · 490 views
10 years ago

I'm using this line in my header in my base.html.twig to automatically pull in summaries for articles:
"<meta name="og:description" property="og:description" content="{{ page.summary }}" /> ", but that ends up adding another bar/content on the top with ' " /> ' of pages that don't have summaries. Added bar

Anyone have any thoughts on what might be a possibility here that's better than having a separate base.html.twig for articles and the non-article pages?

Thanks!

10 years ago

For additional information on it, none of my other opengraph meta tags cause any issue, only setting any of them to {{page.summary}} on non-blog-item pages.

10 years ago

I was able to work around this by setting this in the headers for the pages that had the issue:
summary:
enabled: '1'
format: short
size: 1

10 years ago

You could "make" a summary by taking the content and cutting it down to a suitable length, but you could also just revert to the site description in lieu of a page's summary, like this:

TWIG
{% if page.summary %}
<meta property="og:description" content="{{ page.summary|striptags|raw }}">
{% else %}
<meta property="og:description" content="{{ site.description|e('html') }}">
{% endif %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2956 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago