DEV Community

Gerardo Andrés Ruiz Castillo
Gerardo Andrés Ruiz Castillo

Posted on • Originally published at geanruca.gitvlg.com

Improving SEO and Indexing with Canonical Tags and Robots Configuration

Introduction

Maintaining a website's search engine optimization (SEO) and ensuring proper indexing by search engines like Google is crucial for visibility. This involves carefully managing canonical tags, robots configurations, and handling various URL parameters. Recent updates to the landing page project focused on addressing duplicate canonical tags and Google Search Console indexing issues to improve overall site health.

The Problem

The website experienced several SEO-related problems:

  1. Duplicate Canonical Tags: Multiple canonical tags on a single page confuse search engines, hindering proper indexing.
  2. Indexing Issues: Google Search Console reported issues with indexing, potentially caused by URL parameters or incorrect robots configurations.
  3. Unintended Indexing: Certain pages, like the newsletter unsubscribe page, were being indexed despite not being intended for public search.

The Solution

To address these issues, several changes were implemented:

  1. Removal of Duplicate Canonical Tags: The seo-meta tag was removed from the portfolio layout to eliminate duplicate canonical tags, ensuring a single, authoritative tag per page.
  2. Per-Page SEO Meta Tags: Individual seo-meta tags were added to all stats templates, providing specific and accurate meta information for each page.
  3. Canonical URL Standardization: Query parameters were stripped from canonical URLs to avoid fragmentation and ensure consistent indexing.
  4. Noindex for Unsubscribe Page: The newsletter unsubscribe page was set to noindex to prevent it from appearing in search results.
  5. Robots Configuration Update: The robots configuration was updated to disallow .md routes, preventing the indexing of markdown files.

For example, the canonical URL standardization was achieved by implementing a function similar to this:

function stripQueryParams(string $url): string
{
    $parts = explode('?', $url, 2);
    return $parts[0];
}

$canonicalUrl = stripQueryParams($currentUrl);
Enter fullscreen mode Exit fullscreen mode

This function removes any query parameters from the current URL, ensuring that the canonical URL is clean and consistent.

Results

These changes resulted in:

  • Elimination of duplicate canonical tag errors.
  • Improved indexing status in Google Search Console.
  • Prevention of unintended page indexing.
  • A more streamlined and SEO-friendly website structure.

Getting Started

  1. Audit your website for duplicate canonical tags using SEO tools.
  2. Review your Google Search Console for indexing issues.
  3. Implement URL standardization to remove unnecessary parameters from canonical URLs.
  4. Use noindex tags for pages that should not be indexed by search engines.
  5. Regularly update your robots configuration to control search engine access.

Key Insight

Proactive management of canonical tags, URL parameters, and robots configurations is essential for maintaining a healthy SEO presence and ensuring accurate indexing by search engines. Regularly auditing and updating these elements can significantly improve your website's visibility and search performance.

Top comments (0)