Make your React web apps discoverable – JavaScript SEO


if you are building single page apps you might be using a JavaScript framework to do so one of the most popular frames is react react influenced a series of other structures and is also known for introducing a Dom extraction layer and a domain-specific language to write component templates announced JSX the virtual Dom that act ships with will come in handy when we are trying to make sure our users get to the content as fast as possible as the authorities concerned will last-minute realise so what do you need to do to make sure your react apps are discoverable in pursuit and how do you treat SEO let’s start looking at a ordinary react app while your react programmes might be different in the libraries and components you use and that material and complexity there’s a lot that all react employments approximately have in common for this video we will start by creating a fresh app applying the generate act app helper practicality in this video we are using create react app version 2.0 to and first we develop the lotion skeleton using this command this created a very basic react app for us to work with for this video so let’s take a look at it by running the indicated growth server we can install via NPM as well so if our our work only has one piece of content let’s make this more interesting by adding another itinerary and another piece of content first we invest act router Dom now that we have a router to handle different pages we can add a component for another page we will be using a placeholder API to deliver a few cases uprights so we will call this the posts list component when this factor is ready to be displayed we fetch the data from the API endpoint and store it truncate it a little bit and save it in the components neighbourhood district in the yield method we map the posts to register entries containing the post title and then render all the posts in a listing moving on to our app factor we import the router along with switch and superhighway components and change the yield affair so that we render the posts registers ingredient instead of the header and motto this is a good time to throw out the default CSS as well and then check our app in the browser we now see a roll of pole designations as we are hoping so similar to the posts register ingredient we can now add a component announced pole detail to show one individual article with the entitlement as the headline and the content below it it is very similar to the post list except we only fetch one post from the API and we make the ID from the post from the URL constants let’s add this factor to our router setup last but not least we will set up our affix list components so that it supplies links to each of these article pages we will use the link ingredient from act router for this now we build our projection and deploy it somewhere with our tests application use we can look into improving the discoverability of it so users can find our material more easily on the web a good first stop to check how we are doing is the mobile-friendly test we just set the URL into the field and we realise what Googlebot assures when crawling our pages we see that all our content shown in and that constructs are a labels with an href aspect which is what Googlebot will pick up and creep so our material will be indexed but we can do better here first of all we want to make sure to give meaningful illustrative deeds and descriptions to all our sheets for the home page that can be the name of the blog as the entitle and what this blog is about as the description for the individual post pages we should set the entitlement to the post title and the description to the most important takeaways or summary pit we don’t have that information here so instead for the description we will precisely use the first 100 reputations from the blog post note that this is an arbitrary length the meta description does not have any length regulations but putting in the entire post ponton into it isn’t very useful either to do this and react we can use the helmet component that we invest from NPM or yarn and then add it to the render method in our components we can configure the entitlement the canonical URL as well as any meta labels now if we check one of the post pages in the mobile-friendly test we recognize the claim is the same as the blogpost wording this is great because it helps users searching for a specific topic to see how the blog berth is relevant for their goal the same is true for the description we present a snippet from the description and the search results to help users make an informed decision on which reaction is the best for their needs all right let’s look at a more complex topic as we are indicated in a previous video when we crawl your pages we shelve summary executions of JavaScript to a later instant when resources for rendering are available this leads to two ways of indexing the first one that isn’t lead JavaScript and then potentially a few seconds one where we execute JavaScript to see the content that depends on it if your material mutates very frequently or your locate is very large you might want to make sure to have your content be available in the first motion of indexing so without JavaScript it is also a good intuition to not depend on JavaScript too much as other BOTS might not implement it at all and you might find that you gain a better execution for customers as well if you do not rely on JavaScript to expose your material luckily greeting has a few ways of supporting us with reducing the reliance on JavaScript by doing server-side hybrid or dynamic rendering in our precedent the content won’t change that often so we can use a mixture like react grab to pre render our content and deploy the resulting static documents let’s install act cracking and take it for a slant here it is crawling all our pole sheets if we now look at the source of our sheet in the browser we can see that these files contain our material even if JavaScript hasn’t been implemented setups like this are not ever this easy to accomplish but there’s plenty of documentation of to find out more about the other possibilities for server side or pre-rendering with react we could also decide to only serve the pre-rendered version to bots like google bot that would be called dynamic rendering in which case do take a look at our dynamic interpreting documentation as well I propose you too take a look at the other videos of this sequence for more immense tips on constructing your app discernible and successful with Google search we have a couple more escapades about JavaScript SEO coming out so abide aria and please tell us what you think so far in the comments below and likewise like and share if you are finding our brand-new succession helpful see you soon

As found on YouTube

What's your reaction?

In Love
Not Sure

You may also like