Our title budget is 60 characters, the layout quietly spends ten of them, and a test reads our own source files to prove it
Notifio sells a desktop app that watches rental search pages, and the website around it is about forty pages: a hub and a page per site it can monitor, a page per competitor, a few guides, and the usual static set. Every one of those needs a <title> short enough to survive a search result and a description short enough to survive a snippet. Roughly 60 characters for the title, roughly 160 for the…
Notifio provides a desktop app that monitors rental search pages across multiple websites. Each site requires a title no longer than 60 characters and a description no longer than 160 characters to avoid truncation by search results. The challenge lies in counting the characters, as the actual number of characters may differ from what is typed.
The root layout includes a metadata object with a title default and a template. When a title is declared, such as "Rental Alert Tools Compared – Prices & Trade-offs," it results in a 59 character title, exceeding the allocated budget by 10 characters. These ten characters are unavoidable and occur on every page except the home page.
To address this issue, a test was created to verify the character count of each page's title. The test imports TypeScript objects containing the metadata for different types of pages, such as per-site alert pages, comparison pages, guides, and audience pages. However, the alerts barrel uses extensionless imports that Node cannot resolve, making it difficult to test.
The test function, `literalField`, reads the metadata object literal as text, extracts the value of a specific key (e.g., "title"), and validates the length using a regular expression. This method allows the test to verify that the title length adheres to the defined budget, even for pages that are difficult to import into a Node test environment.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.