Hi,
metadata on websites not overwrite metadata settings/site
if each page has a unique title and description to add the description on pages it is doubled.
sorry for my English
Hi,
metadata on websites not overwrite metadata settings/site
if each page has a unique title and description to add the description on pages it is doubled.
sorry for my English
Hmmm, I remember having the same problem, but not quite sure how I managed to solve it, anyway, here is what works for me:
For every custom blueprint I added this file:
header.metadata:
toggleable: true
type: array
label: PLUGIN_ADMIN.METADATA
help: PLUGIN_ADMIN.METADATA_HELP
placeholder_key: PLUGIN_ADMIN.METADATA_KEY
placeholder_value: PLUGIN_ADMIN.METADATA_VALUE
And then I add this for every page
{% for meta in page.metadata %}
<meta {% if meta.name %}name="{{ meta.name }}" {% endif %}
{% if meta.http_equiv %}http-equiv="{{ meta.http_equiv }}" {% endif %}
{% if meta.charset %}charset="{{ meta.charset }}" {% endif %}
{% endfor %}
I defined some global metadata in the config, and page specific metadata seems to override the site metadata when set with this solution.
Hope it helps!
thank you
Better to create a partials/metadata.html.twig and put that logic in there. Then you can just include this partial on every page, or better yet, in a base that all other pages extend.
I understand, forgiveness in the default template is an example.
https://github.com/getgrav/grav-theme-antimatter/blob/develop/templates/partials/metadata.html.twig
exactly, it's not a requirement but it's a good methodology to follow.
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1368 | 9 years ago | ||
| 2 | 940 | 9 years ago | ||
| 2 | 4069 | 9 years ago | ||
| 1 | 2960 | 9 years ago | ||
| 3 | 1125 | 9 years ago |