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

Optimize the open graph tag in gatsby #2829

Closed
calpa opened this issue Nov 7, 2017 · 5 comments
Closed

Optimize the open graph tag in gatsby #2829

calpa opened this issue Nov 7, 2017 · 5 comments

Comments

@calpa
Copy link
Contributor

calpa commented Nov 7, 2017

Currently, I am using react-helmet to insert the open graph meta tag in the header. However, the tag is also added with react-helmet="true" attribute.

Another approach is to insert those open graph meta tag in the html.js, but I wonder how to receive different information in different pages.

Any ideas?

@KyleAMathews
Copy link
Contributor

Does the extra react-helmet="true" cause any trouble?

@sebastienfi
Copy link
Contributor

It raises and invalid tag warning on SEO analysers, W3C specs says the meta tag shouldn't add any more attributes.

@KyleAMathews
Copy link
Contributor

React Helmet is a far superior way to manage meta tags than doing it in html.js which is why we encourage its usage. But yeah, it's not cool they're adding this.

There's this issue there nfl/react-helmet#79

Perhaps the easiest thing to do is do postBuild find/replace with a regex to remove the attribute from HTML pages?

@jonathan-chin
Copy link

jonathan-chin commented Jan 18, 2018

I came across this exact problem. I added two lines in my package.json that should be set-and-forget:

"scripts": {
      "build": "gatsby build; npm run scrub-react-helmet",
      "scrub-react-helmet": "grep -rl ' data-react-helmet=\"true\"' ./public | xargs sed -i '' 's/ data-react-helmet=\"true\"//g'",
      ...
}

**update
seems it doesn't play well with continuous deployment in Netlify. potentially, it could if I knew more about how the environment is set up. for now, I'm building locally and pushing public/ to gitlab, for now.

@KyleAMathews
Copy link
Contributor

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

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

4 participants