简体   繁体   中英

How do I setup for Each page custom META and related Information for the Page with ReactJS Router

I'm new to ReactJS, And I have set up my new project using Router and added few pages, so my question is how can I set up different head meta and other tags for each custom page. And will this render by Google and show my pages to Google as normal page?

you can set meta and other tags with react-helmet.

Install from here https://www.npmjs.com/package/react-helmet

Suggestion ->Create one component and set with props.

Something like this

import React from "react";
import {Helmet} from "react-helmet";
 
class Application extends React.Component {
  render () {
    return (
        <div className="application">
            <Helmet>
                <meta charSet="utf-8" />
                <title>My Title</title>
                <link rel="canonical" href="http://example.com/" />
            </Helmet>
            ...
        </div>
    );
  }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM