- Issue created by @monaw
Here's a blog post https://www.morpht.com/blog/unleashing-power-metatag-custom-tags which would help you.
I'll write a drupal org handbook page for custom tags- π§πͺBelgium gillesbailleux La Roche-en-Ardenne
Greetings,
@naveenvalecha's blog post begins with an example of a custom meta tag:
<link rel="alternate" type="application/rss+xml" href="https://example.com/rss.xml">
The blog post continues with a custom meta tag added through the metatag_custom_tags module:
<meta name="sitename" content="Custom Meta Tag - Demo Site">
To my understanding, the metatag_custom_tags module currently allows two attributes and not three as mentioned in the first example.
Here is the custom meta tag I would like to create:
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
Here are the informations implemented in /admin/config/search/metatag/custom-tags/icon:
- Name: icon
- Description: SVG favicon
- HTML element: Link
- Attribute name: Rel
- Value attribute: Href
Adding the value /favicon.svg in the custom tags field, this generates the following custom tag:
<meta rel="icon" href="/favicon.svg" />
How do I add the type="image/svg+xml" attribute in the custom tags field? Not with a comma because this generates two custom tags. Neither with a pipe: I tried numerous possibilities and none worked.
Please tell me how to add the type="image/svg+xml" attribute. Thank you.
@gillesbailleux
The Custom Meta tags is designed to support the single html attribute.
I have updated the blog post to reflect that https://www.morpht.com/blog/unleashing-power-metatag-custom-tags
I have also updated the issue title and description and converted it to a feature request to seek @damienmckenna thoughts and approval on it before doing the code changes.- πΊπΈUnited States damienmckenna NH, USA
This would be a great feature improvement for 2.2.x
- Merge request !178Issue #3488276 by Naveen Valecha, gillesbailleux, monaw, damienmckenna: Custom Meta tags - Support multiple attributes β (Open) created by naveenvalecha
- π«π·France musa.thomas France π«π·
hello there i come from this issue https://www.drupal.org/project/metatag/issues/3498656 π Custom Meta tags: Allow - in the machine name of the tag Active but it seems not to be integrate here. Also we need to insert colon inside the tag name (the regex become 'replace_pattern' => '[^a-z0-9_-:]+',)
@musa.thomas Thanks for your comment. Would you care to provide which metatag are you trying to create i.e. output
Example<meta name="nid" content="13" />
- Status changed to Needs review
about 1 month ago 5:28pm 1 May 2025 - πΊπΈUnited States damienmckenna NH, USA
Thank you for working on this, it will be a great improvement once it's finished.
Testing this locally I see some issues:
- The existing standard process of the custom tag's machine name being used as the "name" attribute is removed, so this will break backwards compatibility.
- It doesn't indicate that the new attributes are required, otherwise no "name" attribute will be output.
- It doesn't indicate that the name and value fields should be required, otherwise they will be excluded from the output.
- No indication is given that the extra attributes cannot be edited through the defaults or per-entity forms, they're fixed values for all uses of that custom tag.
So it still needs a little work but is almost there.
- πΊπΈUnited States Maeglin
The existing practice of making a custom tag's name attribute the same as the machine name is also a limitation. No colon characters allowed, for example. Maybe the machine name could be the default if a tag name isn't specified in the definition?
- πΊπΈUnited States damienmckenna NH, USA
Note: I missed that there is an update script that adds an initial attribute for each custom tag already in the system, apologies for my oversight and thank you for taking care of that already.
The other issues still remain though.