Problem/Motivation

I would like to create some custom meta tags for DataCite. I went to the Add Custom tag page @ /admin/config/search/metatag/custom-tags/add but not sure which drop-down option to choose for the 3 fields (HTML element, Name attribute, Value attribute). For example,

  1. what do "Meta" and "Link" mean for the HTML field?
  2. what is the difference between "Name", "Property" and "Item Prop" for the Name attribute field and what do "Http equiv" and "Rel" mean?
  3. what do the "Content" and "Href" choice mean for the Value attribute field?
  4. how do i specify which content field to use for the value?
  5. if a field i want to map to allows multiple input, how to configure that?

Proposed resolution

Perhaps add info about the custom tag configuration to the documentation page

Complete List of HTML Meta tags https://gist.github.com/whitingx/3840905

CommentFileSizeAuthor
#4 custom_tag.jpg176.58 KBgillesbailleux
#4 icon_custom_tag.jpg71.01 KBgillesbailleux

Issue fork metatag-3488276

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

monaw created an issue. See original summary.

naveenvalecha’s picture

Version: 2.1.0 » 2.1.x-dev
Status: Active » Needs review

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

monaw’s picture

thank you @naveenvalecha!

gillesbailleux’s picture

StatusFileSize
new71.01 KB
new176.58 KB

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.

naveenvalecha’s picture

Title: Creating custom meta tag » Custom Meta tags: Support multiple HTML name, value attributes
Component: Documentation » Code
Category: Support request » Feature request
Status: Needs review » Active

@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.

naveenvalecha’s picture

Title: Custom Meta tags: Support multiple HTML name, value attributes » Custom Meta tags: Support multiple attributes
gillesbailleux’s picture

Thank you @naveenvalecha

damienmckenna’s picture

This would be a great feature improvement for 2.2.x

naveenvalecha’s picture

Status: Active » Needs review

@damienmckenna
Could I get your feedback on the post update hook

musa.thomas’s picture

hello there i come from this issue https://www.drupal.org/project/metatag/issues/3498656 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_-:]+',)

naveenvalecha’s picture

@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" />

Have you tried out this PR?

damienmckenna’s picture

naveenvalecha’s picture

Issue summary: View changes
damienmckenna’s picture

Status: Needs review » Needs work

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.

maeglin’s picture

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?

damienmckenna’s picture

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.

eleonel made their first commit to this issue’s fork.

eleonel’s picture

Status: Needs work » Needs review

Thanks damienmckenna and maeglin for the feedback, I pushed some fixes and small improvements.

damienmckenna changed the visibility of the branch 3488276-attributes to hidden.

damienmckenna changed the visibility of the branch 3488276-attributes to active.

damienmckenna changed the visibility of the branch 2.2.x to hidden.

damienmckenna changed the visibility of the branch 3488276-moar-attributes to hidden.

damienmckenna’s picture

Version: 2.1.x-dev » 2.2.x-dev

Thank you for the improvements.

I recreated the MR from scratch against the 2.2.x branch, just waiting for the tests to finish.

  • damienmckenna committed 05b9d70f on 2.2.x
    Issue #3488276 by monaw, naveenvalecha, gillesbailleux, damienmckenna,...
damienmckenna’s picture

Status: Needs review » Fixed

This has been committed. Thank you all!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.