<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CastNova</title>
    <description>The latest articles on DEV Community by CastNova (@castnova).</description>
    <link>https://dev.to/castnova</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3936769%2F6751c3d3-8658-4298-8dda-09be73331f5f.jpg</url>
      <title>DEV Community: CastNova</title>
      <link>https://dev.to/castnova</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/castnova"/>
    <language>en</language>
    <item>
      <title>I had two blog posts ranking against each other. Here's the Next.js fix</title>
      <dc:creator>CastNova</dc:creator>
      <pubDate>Sun, 17 May 2026 19:55:04 +0000</pubDate>
      <link>https://dev.to/castnova/i-had-two-blog-posts-ranking-against-each-other-heres-the-nextjs-fix-2lo3</link>
      <guid>https://dev.to/castnova/i-had-two-blog-posts-ranking-against-each-other-heres-the-nextjs-fix-2lo3</guid>
      <description>&lt;p&gt;A few weeks ago I noticed two posts on my Next.js blog were dragging each other down in Google. Both targeted the same keyword. Both got ~80% of the way to page 1 and stalled. Neither ranked for anything else either.&lt;/p&gt;

&lt;p&gt;Classic keyword cannibalization. I'd written them three weeks apart, didn't remember the first when I wrote the second, and Google couldn't decide which one to surface, so it surfaced neither.&lt;/p&gt;

&lt;p&gt;This post walks through how I diagnosed and fixed it, plus the date-handling gotcha that almost made things worse. Code at the bottom.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to spot cannibalization
&lt;/h2&gt;

&lt;p&gt;Open Google Search Console - Performance - Queries. Click any keyword you care about. Look at the "Pages" tab.&lt;/p&gt;

&lt;p&gt;If two URLs show impressions for the same query, with neither clearly dominating, you have cannibalization. Google is split, it can't tell which one is canonical for that intent.&lt;/p&gt;

&lt;p&gt;The symptom: both posts hover around position 8–15. Neither breaks through.&lt;br&gt;
The diagnosis in my case took 30 seconds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/blog/podcast-to-linkedin-posts (published March 7)&lt;/li&gt;
&lt;li&gt;/blog/podcast-to-linkedin-posts-guide (published March 25)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same primary keyword. I'd literally forgotten about the older post when I wrote the newer one.&lt;/p&gt;
&lt;h2&gt;
  
  
  The decision: merge, not delete
&lt;/h2&gt;

&lt;p&gt;Three options when you have two competing posts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delete the loser, bad idea, you lose every backlink pointing at it&lt;/li&gt;
&lt;li&gt;Add noindex to the loser, Google ignores it, but inbound link equity is wasted&lt;/li&gt;
&lt;li&gt;Merge into one canonical URL + permanent redirect, the only option that preserves everything&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The keep/redirect decision: I picked the older URL as the survivor. Three reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Older posts usually have more inbound links&lt;/li&gt;
&lt;li&gt;Older URL has longer SERP history with Google&lt;/li&gt;
&lt;li&gt;If the newer post has substantially better content, you merge the content INTO the older URL — not the other way around&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So: the survivor's URL stays. The content gets the best of both posts. The loser URL gets a permanent redirect.&lt;/p&gt;
&lt;h2&gt;
  
  
  The architecture problem
&lt;/h2&gt;

&lt;p&gt;Here's where it got interesting. My blog isn't markdown files on disk. It's inline JSX in src/app/blog/[slug]/page.tsx — one big posts: &lt;code&gt;Record&amp;lt;string, BlogPost&amp;gt;&lt;/code&gt; map.&lt;br&gt;
So "merging" wasn't a file operation. It was:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the survivor's entry in the map&lt;/li&gt;
&lt;li&gt;Remove the loser's entry&lt;/li&gt;
&lt;li&gt;Configure a redirect at the framework level, not at the post level&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For Next.js, the cleanest way to handle that is &lt;code&gt;next.config.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// next.config.ts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nextConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;redirects&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/blog/podcast-to-linkedin-posts-guide&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/blog/podcast-to-linkedin-posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;nextConfig&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One gotcha worth knowing: &lt;code&gt;permanent: true&lt;/code&gt; emits a 308, not a 301. Both are "permanent redirect" from Google's perspective and link equity transfers identically, Google confirmed this back in 2016. But if you have monitoring rules that specifically check for 301, you'll need to adjust them. I verified the behavior in production: Google indexed the redirect correctly within 48 hours.&lt;/p&gt;

&lt;h2&gt;
  
  
  The date-handling gotcha
&lt;/h2&gt;

&lt;p&gt;This is where I almost made things worse. When you update a post substantially, you want to signal freshness to Google. The naive fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// DON'T do this&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;podcast-to-linkedin-posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2026-04-25&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// overwriting the original publishedAt&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bad move. You just:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Broke your RSS feed (subscribers see a "new" post that's not actually new)&lt;/li&gt;
&lt;li&gt;Lost the publishedAt signal that Google's freshness algorithm relies on for trust history&lt;/li&gt;
&lt;li&gt;Confused anything that depends on chronological ordering (sitemap-sort, related-posts logic, archive pages)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The right fix is to add an &lt;code&gt;updatedAt&lt;/code&gt; field separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// post interface&lt;/span&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;BlogPost&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;          &lt;span class="c1"&gt;// never change after publish&lt;/span&gt;
  &lt;span class="nx"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;    &lt;span class="c1"&gt;// bump on substantial edits&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in the JSON-LD render:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/blog/[slug]/page.tsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jsonLd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@context&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://schema.org&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Article&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;datePublished&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;dateModified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedAt&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;-- the key line&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the masthead, render the "Updated" line conditionally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;time&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;formatDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;time&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedAt&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; · &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;time&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Updated &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;formatDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;time&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Google sees both signals cleanly: when the post was first published (rank-trust history) and when it was last meaningfully updated (freshness boost).&lt;/p&gt;

&lt;h2&gt;
  
  
  The cleanup grep
&lt;/h2&gt;

&lt;p&gt;Before celebrating, find every internal link pointing at the old URL and update it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# find every reference to the loser slug&lt;/span&gt;
rg &lt;span class="s2"&gt;"podcast-to-linkedin-posts-guide"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't trust your memory. I had 4 internal links scattered across other blog posts that pointed at the loser. Without updating them, every reader gets an extra redirect hop, and a little link equity leaks each time.&lt;/p&gt;

&lt;p&gt;Also check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Footer / nav components&lt;/li&gt;
&lt;li&gt;Any sitemap generator (mine iterates the posts array, so it self-cleaned — but check yours)&lt;/li&gt;
&lt;li&gt;Schema markup generators&lt;/li&gt;
&lt;li&gt;Any hardcoded references using the full https:// URL form&lt;/li&gt;
&lt;li&gt;Middleware (in case you have other redirect logic that could conflict)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The verification
&lt;/h2&gt;

&lt;p&gt;After deploying:&lt;/p&gt;

&lt;p&gt;next build, make sure nothing breaks&lt;br&gt;
Hit the loser URL in browser, watch DevTools Network tab, should be 308 to survivor&lt;br&gt;
Hit the survivor URL, should render with both &lt;code&gt;datePublished&lt;/code&gt; and &lt;code&gt;dateModified&lt;/code&gt; in JSON-LD (verify with Google Rich Results Test)&lt;br&gt;
Request indexing in GSC for the survivor URL, speeds up Google's re-evaluation from weeks to days&lt;/p&gt;

&lt;h2&gt;
  
  
  What to expect
&lt;/h2&gt;

&lt;p&gt;Realistically: 2–4 weeks before you see ranking movement. Google needs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Crawl the redirect&lt;/li&gt;
&lt;li&gt;Consolidate signals onto the survivor&lt;/li&gt;
&lt;li&gt;Re-evaluate ranking based on the unified, deeper content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my case I closed three cannibalization pairs in one session on my &lt;a href="https://castnova.app/blog" rel="noopener noreferrer"&gt;blog at castnova.app&lt;/a&gt;. I'll know in three weeks whether the consolidation lifts the affected URLs into page 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bigger lesson
&lt;/h2&gt;

&lt;p&gt;Cannibalization compounds. Two posts - both stall. Five posts on overlapping intents - your whole topical cluster underperforms, because Google can't form a clean ranking signal for any single one.&lt;/p&gt;

&lt;p&gt;The fix is mechanical (merge + redirect + grep), but the prevention is editorial: before publishing a new post, search your own blog for related keywords. If something already exists, extend it instead of writing a parallel post.&lt;/p&gt;

&lt;p&gt;If you're running a Next.js blog with inline posts (not MDX files), the merge operation is even simpler than the markdown file case, one map edit, one config entry, done. The hard part isn't the code, it's catching yourself before you write the duplicate post in the first place.&lt;/p&gt;

</description>
      <category>marketing</category>
      <category>nextjs</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
