The-DevOps-Daily/devops-daily

feat: Add canonical URL audit and consistency check

Open

#545 geöffnet am 2. Dez. 2025

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (392 Forks)github user discovery
enhancementgood first issuehacktoberfest

Repository-Metriken

Stars
 (1.087 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Description

Audit all pages for proper canonical URL tags and ensure consistency across the site to prevent duplicate content SEO issues.

Problem

  • Canonical URLs may not be set on all pages
  • Risk of duplicate content penalties
  • Inconsistent URL patterns across site
  • No automated verification of canonical tags

SEO Impact

  • Search engines may index wrong version of pages
  • Duplicate content dilutes page authority
  • Could affect search rankings
  • Wasted crawl budget

Pages to Audit

Content Pages

  • Posts: /posts/[slug]
  • Guides: /guides/[slug] and /guides/[slug]/[part]
  • Quizzes: /quizzes/[slug]
  • Games: /games/[slug]
  • News: /news/[slug]
  • Exercises: /exercises/[id]

Listing Pages

  • Homepage: /
  • Posts index: /posts
  • Guides index: /guides
  • Quizzes index: /quizzes
  • Games index: /games
  • Tags: /tags/[tag]
  • Categories: /categories/[slug]
  • Authors: /authors/[slug]

Paginated Pages

  • Check if pagination exists
  • Ensure proper canonical for paginated results

Current State Check

# Search for canonical tags
rg '<link rel="canonical"' app/

# Check metadata generation
cat app/*/page.tsx | grep canonical

Proposed Solution

  1. Audit existing canonical tags
  2. Add canonical to all page metadata
  3. Create utility function for canonical URLs
  4. Add automated tests

Implementation Example

// lib/canonical.ts
export function getCanonicalUrl(path: string): string {
  const baseUrl = 'https://devops-daily.com';
  return `${baseUrl}${path}`;
}

// In page.tsx
export const metadata: Metadata = {
  title: 'Post Title',
  alternates: {
    canonical: getCanonicalUrl('/posts/my-post')
  }
};

Acceptance Criteria

  • Audit all pages for canonical tags
  • Create canonical URL utility function
  • Add canonical to all page metadata
  • Ensure consistent URL patterns (trailing slashes, etc.)
  • Add automated test for canonical tags
  • Verify in production with view-source
  • Add to SEO checklist
  • Document canonical URL conventions

Testing

// tests/canonical-urls.test.ts
import { describe, it, expect } from 'vitest';
import { getCanonicalUrl } from '@/lib/canonical';

describe('Canonical URLs', () => {
  it('generates correct canonical URL', () => {
    expect(getCanonicalUrl('/posts/test')).toBe(
      'https://devops-daily.com/posts/test'
    );
  });

  it('handles trailing slashes', () => {
    expect(getCanonicalUrl('/posts/test/')).toBe(
      'https://devops-daily.com/posts/test'
    );
  });
});

Files to Create/Modify

  • lib/canonical.ts - New utility
  • tests/canonical-urls.test.ts - New tests
  • All page.tsx files - Add canonical metadata
  • docs/seo.md - Document canonical URL strategy

Contributor Guide