Don't forget about Open Graph
Open Graph protocol is a web standard originally developed by Facebook that turns any webpage into a graph object with title, description, image and so on. Even though there is no direct correlation between OG meta tags and improved SEO rankings, it still drives more traffic to your webpage by making it more «attractive» in social networks (Facebook, Twitter, Linkedin, etc).
Without further due let«s jump into newly created React app with
Now, what if I need to generate tags dynamically for every page? That«s easy!
An example of a link shared in Twitter that has «og: image» and «og: title».
Adding OG (and not only) meta tags into your React app
Without further due let«s jump into newly created React app with
create-react-app
and OG meta tags to /public/index.html
. It should look like something like this:
Awesome App
Dynamic tags
Now, what if I need to generate tags dynamically for every page? That«s easy!
We«ll use React Helmet. So let«s create a separate component for document head management, which will dynamically set title, description, image for the page.
import React from 'react';
import Helmet from 'react-helmet';
function SEO({ pageProps }) {
return (
{pageProps.title}
)
}
export default SEO;
Wherever we want to set our meta tags, we«ll just mount SEO component to necessary arguments just like