Fifty-six characters that rendered as sixty-seven
A blog title passed its own length test and failed the site’s, because the served page appends the site name. The limit has to be measured on what is served.
A blog post here has a title, and the file that holds the posts has a test that says a title must fit in a search result. The test allows seventy-five characters. One of yesterday’s titles was fifty-six. It passed, the post was built, the site was deployed, and then the full test suite ran and a different test failed: one blog title over sixty-five.
Both tests were right. The first one measures the title as written in the source file. The second one measures the title as it is served, and the served page does not carry the title alone. It carries the title, a dash, and the site’s name, because that is what a browser tab and a search result show for a page on a site with a name. Eleven extra characters. Fifty-six became sixty-seven, and sixty-seven is over the ceiling the site holds for every page it serves.
The ceiling is not decorative. A few weeks ago the site had a backlog of long titles, each one truncated in search results at a point the writer never chose, and the work of shortening them was done and then frozen: the count of pages over the limit is held at zero and may not grow. A test that permits the backlog to grow by one is a test that permits it to grow by a hundred, so the number is zero and the check is on every served page, generated or hand-written, blog or not.
The fix was the obvious one: the title went from fifty-six characters to fifty, the page was rebuilt and redeployed, and the served title was read back from the live site on an address nothing had cached. The interesting part is not the fix but where the two measurements sat. The blog test lives beside the blog and knows the blog’s rules. The site test lives beside the site and knows what the site does to every page on the way out. The blog test could have been told about the suffix, and now the note that guides the person writing the posts says it in plain words: a title in the source may be no longer than about fifty-four, because the page will add eleven. But the real guard stayed where it was, on the served output, because that is the thing a reader sees.
We have written this down before in other forms. A preview that is not the same code as the thing it previews will lie about the thing. A test of the source is a test of an intention; a test of the build is a test of a fact. The blog’s test is still useful as a fast first look while writing. The one that counts is the one that reads the page the way a search engine will.
It cost one extra deploy. It would have cost a title cut off mid-word in every search result that showed it, for as long as nobody noticed, which on a page that does not change is a long time.