Agent Wranglers

SEO-43Recommended

Write titles search engines keep

Write each title so the search engine has no reason to replace it. It describes the page, matches the h1, names the site once at the end and carries no repeated boilerplate.

How to do it

Google writes its own title link when it finds a problem with the <title>. The problems it lists are half-empty, outdated or inaccurate titles, and repeated boilerplate. Others are a page with no clear main title, the wrong language, and the site name repeated. It builds the replacement from the h1, og:title, large text on the page and the text of links pointing at the page. The closer these agree with the title, the more likely yours stays. Put a year in a title only when the content is updated for that year. The format and length live in Give every page its own title.

Examples

JavaScript example

const name = page.title.replace(/\s*·\s*Example$/, '');
const agree = (a, b) => a.toLowerCase().includes(b.toLowerCase()) || b.toLowerCase().includes(a.toLowerCase());
assert.ok(agree(name, page.h1) && agree(name, page.ogTitle), `${page.path}: title, h1 and og:title disagree`);
assert.equal(page.title.split('Example').length - 1, 1, `${page.path}: site name must appear once`);

Python example

name = re.sub(r"\s*·\s*Example$", "", page.title)
agree = lambda a, b: a.lower() in b.lower() or b.lower() in a.lower()
assert agree(name, page.h1) and agree(name, page.og_title), f"{page.path}: title, h1 and og:title disagree"
assert page.title.count("Example") == 1, f"{page.path}: site name must appear once"

How to check

A build test strips the site name from each title and compares the rest with the page's h1 and og:title. They are equal, or one contains the other, and the site name appears in the title exactly once.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/seo/search-result-appearance/title-rewrites">Agent Wranglers SEO playbook</a>. In code you write, add a comment next to it with the same link.