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

Injected Open Graph meta tags interferes with already existing ones #476

Closed
hf02 opened this issue Dec 19, 2023 · 4 comments
Closed

Injected Open Graph meta tags interferes with already existing ones #476

hf02 opened this issue Dec 19, 2023 · 4 comments

Comments

@hf02
Copy link
Contributor

hf02 commented Dec 19, 2023

It seems that Neocities now injects Open Graph tags if the user agent is detected to be a bot. However, if your website already has Open Graph tags, they interfere and give inconsistent results across platforms.

Example

With a plain webpage I created for this issue.

It displays my metadata on Discord:

image

However, it displays Neocities' injected metadata on Signal.

image

Solution

Perhaps something similar to GitHub Pages' .nojekyll to show that you don't want the meta tags, so you can have full creative control over your webpage.

@hf02
Copy link
Contributor Author

hf02 commented Jan 31, 2024

Found a workaround. You can break it by putting a space in the head's closing tag, causing no meta tags to be injected:

<head>
    <!-- ... -->
</head >

You can see it working on the Nu HTML checker with Discordbot's user agent.

@kyledrake
Copy link
Member

The reason specifically that your example is not working is because it's not correctly formed open graph meta. See the spec here: https://ogp.me/

It is possible that your version works on certain sites but it is not supposed to work, it is the incorrect properties, per the spec.

I'm resolving this issue by being a lot more liberal with how the og detection works, which should resolve this and similar issues (a bunch of newlines in the tag, single quotes vs double). Expect this to be deployed in the next few days.

@hf02
Copy link
Contributor Author

hf02 commented Jan 31, 2024

The reason specifically that your example is not working is because it's not correctly formed open graph meta. See the spec here: https://ogp.me/

Oh my god I feel dumb. Thanks!

@kyledrake
Copy link
Member

The reason specifically that your example is not working is because it's not correctly formed open graph meta. See the spec here: https://ogp.me/

Oh my god I feel dumb. Thanks!

No worries, I think your way also works in practice, likely most people support it as an extra thing even though it isn't documented.

Regardless the newlines are also an issue with our detection. The new approach is we're just going to look for "og:image" and friends as just a string without checking for meta, head, or location of that, and if we see it at all, we won't inject the data.

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