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

using null to remove an existing head tag #179

Closed
1 task
719media opened this issue Jul 25, 2023 · 5 comments
Closed
1 task

using null to remove an existing head tag #179

719media opened this issue Jul 25, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@719media
Copy link
Contributor

Describe the feature

When doing something like

meta: [{
  property: 'og:video',
  content: null,
}]

it actually creates

<meta property="og:video" content="null">

I was attempting to use null as a means of "unsetting" the meta property, but obviously it did not work. The same happens with undefined.

Not sure if this creates other problems of deduplication, etc., but it would be nice if this worked.

The specific use case is removing a meta tag that's defined in index.html outside of unhead.js... unhead will REPLACE existing head tags, but to remove?? not sure

Additional information

  • Would you be willing to help implement this feature?
@719media 719media changed the title using value of null for meta tag feature request - using null/undefined to remove an existing head tag Jul 25, 2023
@harlan-zw
Copy link
Collaborator

harlan-zw commented Jul 25, 2023

This should actually be the behavior, will look at fixing it, specifically passing null as the content.

Thanks!

@harlan-zw harlan-zw changed the title feature request - using null/undefined to remove an existing head tag using null to remove an existing head tag Jul 25, 2023
@harlan-zw harlan-zw added the bug Something isn't working label Jul 25, 2023
@cbedwell-dev
Copy link

cbedwell-dev commented Jul 31, 2023

I agree, this would be a very helpful feature! I use hid's to override meta tags on each page, and when the values of these tags are null it creates an undefined tag, rather than ignoring them completely and defaulting to the tags at the global level.

Any updates on this feature? Thanks

@harlan-zw
Copy link
Collaborator

Oh ye I forgot to update this, with the latest version (1.7.2) this will remove the meta tag .

Let me know if you have any issues with it.

@719media
Copy link
Contributor Author

It works according to one definition.
One example up for debate is if your raw html (before unhead) has a meta tag:

<html>
  <meta property="og:image" content="https://domain.com/image.jpg">

And unhead has a meta tag definition of

{
  property: 'og:image',
  content: null,
  tagPriority,
}

You could say that the null should remove the original og:image defined in html. In the case of current unhead logic, it's treating the null as more of a "fallback to whatever was in original html"

As such, there's not an "easy" way to remove original html meta tags from unhead. The workaround is to remove them "manually" upon unhead initialization.

@harlan-zw
Copy link
Collaborator

harlan-zw commented Sep 14, 2023

Good point, have moved to this issue to track #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants