惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Google Was Rewriting My Title. The Cause Was a Single JSX...
Ted · 2026-05-22 · via DEV Community

Ted

A page I manage was sitting at position 1 for its primary keyword. Over about three weeks it slid to position 9. When I checked the SERP on mobile vs desktop, the title showing in results was different on each device — and neither matched the title tag in the HTML.

That's the tell. Google doesn't rewrite titles randomly. It rewrites them when the page gives it a better candidate string than the one in <title>. I had done exactly that, without realising it.

The two causes

1. Title tag over the display limit

Google's rendered title in search results is constrained to roughly 600px width — around 55–60 characters depending on the character set. When the <title> tag exceeds that, Google looks for a shorter, cleaner alternative on the page: the H1, a prominent heading, or any large text near the top of the document.

My title tag was 69 characters. Not catastrophic on its own, but it opened the door.

2. Subtitle span nested inside the H1

This was the actual cause. The pattern looked like this — examples below are illustrative, but this structure appears on any content page with a heading and a subtitle:

<h1 className="text-4xl font-bold">
  Best Coffee Shops in Austin
  <span className="text-muted-foreground text-2xl">
    2026 Neighborhood Guide – Updated Weekly
  </span>
</h1>

Enter fullscreen mode Exit fullscreen mode

To a human reading the rendered page, this looks like a heading with a subtitle underneath it. To Google's parser, it reads the entire <h1> content as one string:

Best Coffee Shops in Austin 2026 Neighborhood Guide – Updated Weekly

Enter fullscreen mode Exit fullscreen mode

That's longer than intended — and in my case it also contained stale data that had since changed. Google preferred the H1 string, started using it, and because it was being pulled from the DOM rather than the <title> tag, it varied depending on how the page rendered (full JS execution on desktop vs partial on mobile), producing different titles per device.

The fix

Two changes:

1. Shorten the title tag to under 60 characters

<!-- before: 69 chars — over the display limit -->
<title>Best Coffee Shops in Austin — 2026 Neighborhood Guide by Area</title>

<!-- after: under 60 chars -->
<title>Best Coffee Shops in Austin 2026 — By Neighborhood</title>

Enter fullscreen mode Exit fullscreen mode

2. Move the subtitle out of the H1

// before — subtitle inside H1, Google reads as one string
<h1 className="text-4xl font-bold">
  Best Coffee Shops in Austin
  <span className="text-2xl text-muted-foreground">
    2026 Neighborhood Guide – Updated Weekly
  </span>
</h1>

// after — separate elements, Google reads H1 cleanly
<h1 className="text-4xl font-bold">
  Best Coffee Shops <span className="text-accent">in Austin</span>
</h1>
<p className="text-2xl text-muted-foreground">
  2026 Neighborhood Guide – Updated Weekly
</p>

Enter fullscreen mode Exit fullscreen mode

The <p> is no longer semantically part of the heading. Google now has a much cleaner, more consistent title candidate from the <title> tag and one matching candidate from the <h1>. No competition, no rewriting.

What GSC showed after

Position movement on the main queries within one week of the fix:

Query 6-month avg 7-day post-fix
primary head term 6.5 3.6
secondary variant 6.8 3.0
branded + modifier 5.3 4.1
long-tail variant 6.4 4.7

CTR also moved from 9.9% (6-month baseline) to 11.6% in the first week — the clean title converts better in the result snippet because it's not being truncated or substituted.

The pattern to watch for

In React and JSX, it's easy to put display-only text inside a heading element for layout convenience. A <span> with reduced font size inside an <h1> looks like a subtitle visually but is semantically part of the heading. Google sees the full concatenated string.

Any time you have secondary text near a heading — a date, a price, a tagline — check whether it's inside the heading element or adjacent to it. If it's inside, and your title tag is already near the character limit, you're handing Google an alternate title it may decide to use.

The fix is always the same: move the secondary text to a <p> or <span> outside the heading. One element change. The heading stays visually identical; the semantic structure is now correct.