Site Dominion Blog Image.

It’s crucial to make sure the search engines can tell which version of a given page is the original while developing a website. Canonical tags are useful in this situation. An HTML tag called a canonical tag informs search engines which version of a certain page is the official one. We’ll go over how to add canonical tags to a Next.js website in this blog post.

Step 1: Determine which Pages Need a Canonical Tag

The initial step is to identify the internet pages that call for canonical tags. Pages with various URLs or versions frequently utilize canonical tags. If a blog post appears on multiple pages of your website, for instance, the original blog post should have a canonical tag added to it. Search engines will be able to determine which version is the official one with the aid of this.

Step 2: Install the Next.js Head Component

You can edit the head section of your HTML document using the Head component provided by Next.js. You must run the following command to install the Head component before you can use it:

npm install next/head

Step 3: Add the Canonical Tag to your pages

After setting up the Head component, you can import it and use it to edit the HTML document’s head section to add the canonical tag to your pages. Here’s an illustration:

import Head from 'next/head'

function MyPage() {
return (
<>
<Head>
<link rel="canonical" href="https://example.com/page/inner-page" />
</Head>
<div>
{/* Page content */}
</div>
</>
)
}

To add a canonical tag to the head section of our HTML document, we import the Head component from the “next/head” module in the example above. The URL of the initial blog post was entered as the href attribute of the link tag.

Step 4: Examine Your Canonical Tags

It’s crucial to check that your pages are functioning properly after adding the canonical tag. To make sure your canonical tags are configured properly, you can utilize a tool like Google Search Console.

Summary

Canonical tag addition is a quick and easy operation that can help your Next.js website perform better in search results. You may make sure that search engines recognize which version of your pages is the authoritative one by following the instructions provided in this blog post. This can boost your website’s exposure and search engine rankings.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Site Dominion | www.sitedominion.com
Site Dominion | www.sitedominion.com

Written by Site Dominion | www.sitedominion.com

High end web design, development, branding and scaling solutions

No responses yet

Write a response