Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upany possible way to disable 'data-react-helmet="true"' from server side rendering? #79
Comments
This comment has been minimized.
This comment has been minimized.
|
We currently use that markup to distinguish Helmet's tags from existing tags in the app, in case a user wants tags managed outside of Helmet. The current implementation clears all the tags managed by Helmet and re-adds them. If we eliminated this from the server, we couldn't distinguish on the front end. We will be moving to an implementation that will track individual tags on the front end and only update the changed ones. But for that we still need the client to establish a set of known Helmet-managed tags. We could potentially re-visit why we have separate Helmet-managed tags and consider having Helmet manage everything...or perhaps an opt-in for full management vs. partial management. Hmmm....thoughts? |
cwelch5
added
enhancement
help wanted
and removed
help wanted
labels
Jan 6, 2016
This comment has been minimized.
This comment has been minimized.
pavelkornev
commented
May 11, 2016
|
@cwelch5 Having such an option would be cool |
This comment has been minimized.
This comment has been minimized.
janoist1
commented
Aug 3, 2016
|
Still nothing? |
This comment has been minimized.
This comment has been minimized.
dergachevm
commented
Dec 6, 2016
•
|
Realy need to disable data-attributes from meta tags on server side. I have asked support of Yandex and they say data attributes not allowed in meta tags |
This comment has been minimized.
This comment has been minimized.
svagi
commented
Dec 6, 2016
•
|
@dergachevm As a workaround, you can replace it with empty string. Something like: const Head = Helmet.rewind()
const regexp = / data-react-helmet="true"/g
const attr = Head.htmlAttributes.toString()
const title = Head.title.toString().replace(regexp, '')
const link = Head.link.toString().replace(regexp, '')
const style = Head.style.toString().replace(regexp, '')
const meta = Head.meta.toString().replace(regexp, '')
const script = Head.script.toString().replace(regexp, '') |
This comment has been minimized.
This comment has been minimized.
dergachevm
commented
Dec 12, 2016
|
@svagi Thank you |
This comment has been minimized.
This comment has been minimized.
huygn
commented
Dec 21, 2016
•
|
Anyways I can do this in the client? I have a React client side rendered page and trying to use meta tags for Twitter Card. |
This comment has been minimized.
This comment has been minimized.
staylor
commented
Feb 24, 2017
|
Only remove the data attribute from element sets that aren't already in the
Otherwise, the |
This comment has been minimized.
This comment has been minimized.
gajus
commented
May 8, 2017
•
|
@cwelch5 Can you make In the mean time, a dirty workaround is: require('react-helmet/lib/HelmetConstants.js').HELMET_ATTRIBUTE='data-react';
Personally, I don't feel comfortable exposing the fact that the server-side code is using a particular framework. Exposing in markup that |
This comment has been minimized.
This comment has been minimized.
ncochard
commented
May 31, 2017
|
I am wondering if anybody has evidence that the We are using Our SEO consultant suspect that the attribute Since we are implementing an isomorphic application, removing the So I am considering working on a fork (or pull-request) which does not use the attribute |
This comment has been minimized.
This comment has been minimized.
jfuchs
commented
May 31, 2017
|
I've run into another issue with this data attribute — it breaks Google AMP's [albeit strict] validation for their boilerplate tags. |
This comment has been minimized.
This comment has been minimized.
shahkashani
commented
Jun 1, 2017
|
Please. |
hugmanrique
referenced this issue
Aug 10, 2017
Closed
Option to render output without `data-react-helmet` attrs #304
This comment has been minimized.
This comment has been minimized.
hugmanrique
commented
Aug 10, 2017
|
+1 This is affecting Google's AMP pages |
This comment has been minimized.
This comment has been minimized.
esbb48
commented
Aug 18, 2017
•
|
It also affect Facebook debugger |
This comment has been minimized.
This comment has been minimized.
jcdarwin
commented
Sep 5, 2017
|
In order to deal with this annoying behaviour, you can do this hack, which removes the
|
This comment has been minimized.
This comment has been minimized.
calpa
commented
Nov 8, 2017
|
It affects the Facebook open graph... |
This comment has been minimized.
This comment has been minimized.
elrumordelaluz
commented
Nov 10, 2017
•
|
Same problem here for Twitter Cards |
This comment has been minimized.
This comment has been minimized.
spiral2k
commented
Nov 29, 2017
|
any updates on this one? |
This comment has been minimized.
This comment has been minimized.
adam-26
commented
Dec 14, 2017
|
I have forked react-helmet and removed the There is one caveat, if you include any metadata in your render using alternative methods (not react-helmet syntax), you must assign the HTML element the attribute Obviously it would be preferable if react-helmet included an option to disable use of the attribute, but given this issue is over 2 years old that seems unlikely. As a side note, the fork was originally created to enable support of the react 16 server-side streaming interface. |
This comment has been minimized.
This comment has been minimized.
priteshpoddar
commented
Feb 9, 2018
|
Any updates on this? |
This comment has been minimized.
This comment has been minimized.
milotindragos
commented
Mar 13, 2018
|
Any news on this? |
This comment has been minimized.
This comment has been minimized.
vxcamiloxv
commented
Apr 12, 2018
|
|
This comment has been minimized.
This comment has been minimized.
RobsonAraujo
commented
Apr 17, 2018
|
Our project is using Helmet too and we use server side rendering. When checking the SEO with https://seositecheckup.com/ we get missing tags (especially the description meta tag) although it is there. We suspect that the |
This comment has been minimized.
This comment has been minimized.
championshuttler
commented
May 7, 2018
|
How to add meta tag of twitter card in react-helmet to render dynamic data |
This comment has been minimized.
This comment has been minimized.
flavioalves
commented
Jun 3, 2018
|
+1 |
This comment has been minimized.
This comment has been minimized.
taze-fullstack
commented
Jun 5, 2018
|
+1 |
This comment has been minimized.
This comment has been minimized.
hugmanrique
commented
Jun 6, 2018
|
As this issue is pretty old, there are lots of people subscribed to it through email. We would appreciate if instead of adding +1 comments you used the reactions feature. |
This comment has been minimized.
This comment has been minimized.
cmtt
commented
Jul 13, 2018
|
+1. Using this as workaround and feel bad about it. /**
* Regular expression used in `removeAdditionalHelmetAttributes`.
* @type {RegExp}
*/
const ATTRIBUTE_REGEXP = / data-react-helmet="true"/g;
/**
* Removes "data-react-helmet" attributes from generated HTML, as it
* cannot be currently disabled.
* @method removeAdditionalHelmetProps
* @see https://github.com/nfl/react-helmet/issues/79
* @param {Object} helmet
* @return {Object}
* @private
*/
const removeAdditionalHelmetAttributes = (helmet) => {
return Object.keys(helmet).reduce((previous, acc) => {
const handler = helmet[acc];
const _toString = handler.toString;
const toString = () => _toString.call(handler).replace(ATTRIBUTE_REGEXP, '');
return {
...previous,
[acc]: { ...handler, toString },
};
}, {});
};
// In your middleware:
/**
* Collect properties for Helmet after rendering.
* @type {Object}
*/
const helmet = removeAdditionalHelmetAttributes(Helmet.rewind()); |
This comment has been minimized.
This comment has been minimized.
CanRau
commented
Jul 14, 2018
|
react-head might be an interesting alternative, haven't tried it myself, yet, but it uses React Portals and says it's SSR ready. Medium article Still didn't had the time to test it yet, example app won't install, and the code mentions |
This comment has been minimized.
This comment has been minimized.
outofthisworld
commented
Aug 28, 2018
|
+1 |
This comment has been minimized.
This comment has been minimized.
AndyPresto
commented
Sep 9, 2018
|
Is there any alternative to this issue yet? Apart from hacky workarounds. |
This comment has been minimized.
This comment has been minimized.
hugmanrique
commented
Sep 10, 2018
•
|
This project hasn't received any updates for more than 7 months now. I think it's safe to say that if you want a library that doesn't have this bug, it would be better to search for an alternative (especially considering they would use newer React features such as portals) instead of waiting for the @CanRau suggested an alternative above |
This comment has been minimized.
This comment has been minimized.
CanRau
commented
Sep 10, 2018
|
@hugmanrique @AndyPresto only thing is react-head is still missing some, for me, important features like manipulating |
tmbtech
added
bug
and removed
enhancement
labels
Nov 7, 2018
This comment has been minimized.
This comment has been minimized.
|
Removing the enhancement tag and escalating to a bug. We are in the process of discussing the roadmap for the next update major update and will be addressing some of these bugs. |
This comment has been minimized.
This comment has been minimized.
zolero
commented
Nov 13, 2018
Any ETA? |
This comment has been minimized.
This comment has been minimized.
|
@zolero sorry I do not have an ETA. I wish we had a dedicated team for OOS but the maintainers are volunteers from the engineering department. Please bear with me while I get caught up with the project. |
SkateFreak commentedDec 2, 2015
i don't mind if its in the client but i don't like these extra chars in my markup.
any suggestions?
thanks