On-Page SEO
Title Tags and Meta Descriptions with Claude Code
Audit every title tag and meta description on your site with a free script, rewrite the weak ones with Claude Code, and apply the changes in your codebase.
Your title tag is the blue headline people click in Google, and your meta description is often the grey text underneath. Both are small, both are easy to get wrong across a whole site, and both are a good fit for Claude Code: it can audit every page at once, rewrite the weak ones, and edit the code that produces them.
This guide covers the rules that matter, a script that audits every page in your sitemap, prompts for rewriting, and how to apply the changes in your codebase.
The rules in one table
| Element | Guideline | Why |
|---|---|---|
| Title tag | About 50–60 characters, main topic near the start | Google cuts titles at roughly 600 pixels on desktop |
| Title tag | Unique on every page | Duplicate titles make pages look interchangeable |
| Title tag | Matches the page's H1 topic | Google may rewrite titles that don't describe the page |
| Meta description | About 120–160 characters | Longer descriptions get cut off in results |
| Meta description | Says what the reader gets, in plain words | It's an ad for the click, not a keyword list |
| Both | No keyword stuffing or boilerplate | Google ignores or rewrites stuffed and repetitive text |
Meta descriptions aren't a ranking factor, but they affect whether people click. Google also uses its own snippet when it thinks a different part of the page answers the search better, so a description is a strong suggestion, not a guarantee.
Why Google rewrites your titles
Google builds the title shown in results mainly from your title tag, but it can also use your H1, other headings, or text from links to the page. It does this most often when a title is missing, too long, full of boilerplate, or doesn't match what the page is about.
We saw this on our own site. Our skills page had the title "All Skills — Claude SEO for Claude Code", but its big H1 said "25 PRO SKILLS. One install." Google ignored our title and showed "25 PRO SKILLS. One install. - Claude SEO" instead. The fix was to make the title and the H1 tell the same story.
Step 1: Audit every page with a script
This script reads your sitemap, fetches each page, and reports the title, H1, and any problems: missing or duplicate tags, titles over 60 characters, and descriptions outside 70–160 characters. It uses only Python's standard library. Ask Claude Code to save it as scripts/meta_check.py:
"""Report title and meta description length and duplicates for every page in a sitemap.
Usage: python3 meta_check.py https://www.example.com
"""
import html
import re
import sys
import urllib.request
from collections import Counter
from urllib.parse import urlparse
SITE = sys.argv[1].rstrip("/")
def fetch(url):
request = urllib.request.Request(url, headers={"User-Agent": "meta-check"})
with urllib.request.urlopen(request, timeout=20) as response:
return response.read().decode("utf-8", "ignore")
def first(pattern, text):
match = re.search(pattern, text, re.S | re.I)
return html.unescape(match.group(1).strip()) if match else ""
paths = [urlparse(loc).path or "/" for loc in re.findall(r"<loc>(.*?)</loc>", fetch(f"{SITE}/sitemap.xml"))]
rows = []
for path in paths:
page = fetch(SITE + path)
title = first(r"<title[^>]*>(.*?)</title>", page)
description = first(r'<meta\s+name="description"\s+content="(.*?)"', page)
h1 = re.sub(r"<[^>]+>", "", first(r"<h1[^>]*>(.*?)</h1>", page))
rows.append((path, title, description, h1))
titles = Counter(row[1] for row in rows)
descriptions = Counter(row[2] for row in rows)
for path, title, description, h1 in rows:
problems = []
if not title:
problems.append("missing title")
elif len(title) > 60:
problems.append(f"title {len(title)} chars")
if not description:
problems.append("missing description")
elif not 70 <= len(description) <= 160:
problems.append(f"description {len(description)} chars")
if title and titles[title] > 1:
problems.append("duplicate title")
if description and descriptions[description] > 1:
problems.append("duplicate description")
if not h1:
problems.append("missing h1")
print(f"{path}\n title: {title}\n h1: {h1}\n check: {', '.join(problems) or 'ok'}")Run it against your live site or a local build:
python3 scripts/meta_check.py https://www.your-site.comWhen we ran it on our own site, every page passed except one:
/blog/keyword-research-with-claude-code
title: Keyword Research with Claude Code: From Seed Terms to Page Maps
h1: Keyword Research with Claude Code: From Seed Terms to Page Maps
check: title 63 charsThree characters over isn't a disaster, but it means the end of the title may be cut off in results. That's exactly the kind of small issue that's easy to miss by hand across dozens of pages. We shortened it to "Keyword Research with Claude Code: Seed Terms to Page Maps" (58 characters).
Step 2: Rewrite the weak titles and descriptions
Give Claude Code the audit, plus Search Console data if you have it, so rewrites target the searches people actually use:
Run scripts/meta_check.py against http://localhost:3000. For every page with a problem, and for pages in my Search Console export [file.csv] ranking in positions 3–15 with low CTR, write a new title (under 60 characters, main topic first, brand at the end only if it fits) and a meta description (120–155 characters, says what the reader gets). Keep the title consistent with the page's H1. Show old and new side by side before changing anything.Review the suggestions with two questions in mind: would you click this, and does the page deliver what it promises? If the answer to the second is no, fix the page, not the title.
Step 3: Apply the changes in your codebase
Once you approve the rewrites, ask Claude Code to edit the source. Where titles live depends on your stack:
| Stack | Where to edit |
|---|---|
| Next.js (App Router) | The metadata export or generateMetadata in each page or layout |
| Markdown/MDX blogs | The title and description fields in each post's frontmatter |
| WordPress | Your SEO plugin's fields for each post, or the theme's title template |
| Plain HTML | The <title> and <meta name="description"> tags in each file |
In Next.js, a title template in the root layout adds your brand to every page automatically:
export const metadata: Metadata = {
title: {
default: "Claude SEO Skill & Blog Writer for Claude Code | ClaudeSEO",
template: "%s | ClaudeSEO",
},
};Watch the template on long titles. A 55-character post title plus " | ClaudeSEO" goes over 60 characters, so for blog posts we set an absolute title without the brand suffix.
Step 4: Verify and measure
- Build the site and rerun the script until every page passes.
- Deploy, then request indexing in Search Console for the pages you changed most.
- After two to four weeks, compare clicks and CTR for those pages with the previous period.
Here's what changed on our own site after this process:
| Page | Before | After |
|---|---|---|
| Homepage | Claude SEO — AI SEO & Content Suite for Claude Code | Claude SEO Skill & Blog Writer for Claude Code (plus our brand suffix) |
| Skills | All Skills — Claude SEO for Claude Code | Claude SEO Skill List: 57 Skills & 63 Commands |
| Tutorial | Claude Code for SEO: A Practical End-to-End Workflow | Claude Code SEO Tutorial: A Practical End-to-End Workflow |
Each new title leads with the words people actually search, which we found by checking Google's related searches for our main topic.
Doing this with ClaudeSEO
Title and meta checks are part of the on-page review in the Claude SEO full site audit, and /claudeblog seo-check runs them on a draft post before you publish. Drafts scored with the 100-point content scoring include title clarity and meta descriptions in the SEO category. Every command is on the Claude SEO skill list.
For more on-page work, see our guides to internal linking with Claude Code and writing a blog post with Claude Code.
FAQ
How long should a title tag be?
Aim for about 50–60 characters. Google truncates titles by pixel width (around 600 pixels on desktop), so put the most important words first in case the end gets cut.
Do meta descriptions affect rankings?
Not directly. Google doesn't use the meta description as a ranking signal, but a clear description can increase the share of people who click your result, which is the reason to write one.
Can Claude Code update meta tags across a whole site?
Yes. Claude Code can audit every page, propose new titles and descriptions, and edit the files or metadata code that produce them. Review the changes before you deploy, especially on pages that already rank well.