Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name vs Property in meta tags in page headers #3843

Closed
diziara opened this issue Jul 10, 2024 · 5 comments
Closed

Name vs Property in meta tags in page headers #3843

diziara opened this issue Jul 10, 2024 · 5 comments

Comments

@diziara
Copy link

diziara commented Jul 10, 2024

Context: Mastodon is introducing a new feature where if you include a meta tag with your fediverse handle, they'll put it into the link preview card as the author, making it easier for people to find you and read more of your content. This seems like a useful thing for a blog to make use of, so I decided to try to add the tag to my Grav sites. You can read more about it here: https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

TL;DR: I want to include <meta name="fediverse:creator" content="@[email protected]" /> to my Grav site.

When I attempt to do this using either the admin panel site settings, or by directly editing site.yaml, it instead returns <meta property="fediverse:creator" content="@[email protected]" /> which is not what one needs for this particular meta tag. On the Grav Community forums, the closest we could get it is <meta name="fediverse:creator" property="fediverse:creator" content="@[email protected]" /> which isn't correct because you're not supposed to have both a name and a property attribute in the same meta tag. And if I edit anything else that gets saved to site.yaml via the admin panel (which, let's be honest, with ADHD, I'll likely forget and do so) it'll overwrite the work around we hacked together. https://discourse.getgrav.org/t/fediverse-creator-meta-tag/25652

I can't find anything that allows me to specify which to use, or how it determines which is correct, but in this case it is not resulting in the correct thing. We need to be able to override the automagic detection when it gets it wrong like this... maybe default to whatever process the template uses, but if it's specified then instead use what's specified.

@pmoreno-rodriguez
Copy link
Contributor

Well, it seems that Grav tries to distinguish between social metadata and other types of metadata by using the presence of a colon separator : and the Utils::startsWith() method for specific exceptions. However, the current logic applies property to any key that contains a : separator and does not start with 'twitter' or 'flattr'.
You can see this in the file Page.php, on line 1777. Yes changing that line to

if ($hasSeparator && !Utils::startsWith($key, ['twitter', 'flattr','fediverse'])) {

solves the problem. Now with:

metadata:
 'fediverse:creator': '@[email protected]'

the html output is:

<meta name="fediverse:creator" content="@[email protected]" >

@diziara
Copy link
Author

diziara commented Jul 12, 2024

Okay. So is this something I need to override on my local installs, or is this something that's going to be pushed to the main Grav code base and I can wait for it to get folded in and push with an update? (Since Masto's feature is still in beta anyway, I'm not in a rush.)

@pmoreno-rodriguez
Copy link
Contributor

Well, since it's a small change, I already made a pull request to the Grav development team

@diziara
Copy link
Author

diziara commented Jul 12, 2024

Awesome! Thank you! Hopefully they'll pick it up and include it in the next release. I'll try to keep an eye on it.

@pmoreno-rodriguez
Copy link
Contributor

@diziara. This change has been merged into develop branch of Grav.

You could close this issue if you are ok with solution.

@diziara diziara closed this as completed Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants