Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your Next.js Site Has Four Copies of Every Page. Here Is How to Tell Google Which One Counts

You ship one page. Google can crawl it at four or five different URLs, and it treats every one of them as a separate document until you say otherwise. On a Next.js site deployed to Vercel, most of those duplicates are created by defaults you never chose, and they quietly split your rankings across addresses that should have been one. This is the cleanup pass I do on every service business site…

Next.js sites on Vercel often have duplicate pages due to default configurations that create multiple URLs for the same page. This can dilute a page's ranking by spreading it across different addresses. To consolidate the authority on a single URL, follow these four steps.

First, choose a single host and scheme. Either use the apex domain (example.com) or the www subdomain (www.example.com), and redirect the other version to the chosen one using a permanent redirect in Vercel's Domains settings or middleware. This helps avoid duplicate content caused by having both versions indexed.

Second, decide on a trailing slash policy and let Next.js handle the redirects. Set trailingSlash: false in next.config.js to redirect requests without a trailing slash to the version with the trailing slash. This ensures that all URLs for the same page have a consistent format, reducing duplicate content.

Third, add a canonical tag to each page, pointing to the clean URL without query strings. In the App Router, define the metadata base in app/layout.tsx and set the canonical tag for each page using the slug from the page's data. This signals to Google which URL is the preferred version, especially when dealing with query strings that can't be redirected without breaking attribution.

Finally, exclude preview deployments from being indexed by adding a robots.txt file that includes a noindex directive for environments other than production. This prevents preview domains, custom staging sites, and branch URLs from competing with the live version, keeping the crawl budget focused on the main site. By implementing these four decisions, you can consolidate your Next.js site's pages, improve search rankings, and prevent duplicate content issues.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Remove a Photo Background in the Browser: An On-Device Model, No Upload

I work on OnePassApps. We build browser studios that process files in the tab instead of uploading them, and this is the Image Studio's background remover.

  • Image Studio tool removes photo backgrounds on-device in browser
  • On-device model identifies image subject, downloads once per use
  • Tool processes JPEG, PNG, WebP files up to 25 MiB and 25 megapixels

On-prem runtime security: what leaves your network

Does data leave your network with an on-prem integration runtime? It depends on the design. With the Neblex On-Prem Worker, our local integration runtime (often called an on-prem integration agent)…

  • On-prem integration runtime security focuses on data leaving the network and runtime needs.
  • Neblex On-Prem Worker communicates via one outbound encrypted connection on port 443.
  • Runtime maintains security with TLS 1.3, post-quantum key exchange, and no internet-exposed ports.

My morning terminal: zoxide jumps, mise runs the project, starship shows context, fzf picks the file

You open a terminal many times every day, and most of the time, you follow the same five-minute sequence: get to your current project, run something inside the project, check the terminal prompt, open…

  • Zoxide replaces cd by jumping to project directories via z command
  • Mise automates project setup and build tasks in Node.js projects
  • Starship enhances terminal prompt with git branch and toolchain info

More from Monday 2 November →