kodyl / react-document-meta

HTML meta tags for React-based apps. Works for both client- and server-side rendering, and has a strict but flexible API.
MIT License
320 stars 23 forks source link

google sees the page without meta tags #45

Closed romanown closed 6 years ago

romanown commented 6 years ago

at first glance, everything works well and in the code in the browser you can see meta tags. but when you view the page code there is nothing. and google sees the page without meta tags. I use the module on the product catalog page. all data is transferred. I can see everything in the reaction tools. but Google doesn't see it. after I start using this component, almost all pages are removed from the Google cache. I have "react": "^16.2.0", "react-dom": "^16.2.0", "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "_id": "react-document-meta@3.0.0-beta.2"

danieljuhl commented 6 years ago

@romanown did you remember to include the meta data during server side rendering? https://github.com/kodyl/react-document-meta#server-usage

We have several apps/websites using this without problems.

romanown commented 6 years ago

thank You. should I only do it on the server? or on the client side as it is necessary to do as shown in the example above server example? const meta = DocumentMeta.renderAsHTML(); is not have any arguments and props?

romanown commented 6 years ago

I did it in a file on the server. but received an error. You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: TypeError: _reactDocumentMeta2.default.renderAsHTML is not a function

romanown commented 6 years ago

I have such structure. default node starts the server. app accesses the server as a proxy and receives data.

danieljuhl commented 6 years ago

@romanown it has to be done on the server (as it needs to be part of the initial HTML for Google to be able to see it), and yes, renderAsHTML() has no arguments or props, but has to be called after you React DOM server-side rendering.

Without seeing your full code and knowning your stack, it is hard to debug your issue, but it could be something with the way you import renderAsHTML/react-document-meta.

Can you provide the code for server.js (mainly where you import react-document-meta and where you use it).

romanown commented 6 years ago

thank You. i am changed renderAsHTML to renderAsReact and its working.