Skip to content

Fix duplicate and contradictory messages in ideal length rules - #668

Open
helloDanuk wants to merge 4 commits into
statamic:7.xfrom
helloDanuk:fix/ideal-length-messages
Open

helloDanuk wants to merge 4 commits into
statamic:7.xfrom
helloDanuk:fix/ideal-length-messages

Conversation

@helloDanuk

@helloDanuk helloDanuk commented Sep 17, 2026

Copy link
Copy Markdown
Contributor
Bildschirmfoto 2026-09-17 um 15 20 39

Problem

The page details of IdealTitleLength and IdealMetaDescriptionLength show confusing messages:

  • Duplicate text: when a value is missing or too long, the description and the comment show the same sentence twice.
  • Contradicting text: a page with an ideal length gets the description "Your title tag is too long." while the comment says "(ideal length)".
  • No target for slightly too long values: the description says "too long", but no length target is shown.
  • Misleading target: "Ideal length is < 70" names the fail threshold instead of the ideal range, so a 65 character title still gets a warning.
  • Hard-coded limits in the fields: the title and description fields say "ideally less than 60 / 160 characters" and count up to 60 / 160 characters, regardless of the reports config. The instructions also omit the minimum.
  • Wrong length for non-ASCII text: strlen() counts bytes, so e.g. German or French titles are measured too long.

Solution

pageDescription() already returned case-specific descriptions (missing / too short / too long), but every other case fell back to "too long", and the comments reused the same keys. This PR completes that approach:

  • The description names the case: missing, too short, within the ideal length range, too long.
  • The comment gives the length and, if outside the ideal range, the range from warn_min / pass_max. No comment when the value is missing.
  • The title and description fields use the same values from the config: the instructions show the range ("ideally 30–60 characters long", updated in all languages), the character limit uses pass_max.
  • Length is measured with mb_strlen().

No translation keys were added or removed, but four keys per rule change their meaning: …_page, …_page_failing_too_short, …_page_failing_too_long and …_page_warning (…_page_passing is only shortened). en, de, de_CH and nl are updated; apps that override these keys in lang/vendor/seo-pro will need to update them.

Before / after

Examples use the default config: title 30 / 60 / 70, meta description 120 / 160 / 240 (warn_min / pass_max / warn_max).
In each cell, the first line is the rule description, the second line (italic) is the comment shown below it in the page details.

Title length

Case Status Before After
Missing ❌ Fail Title tag is missing.
Title tag is missing.
Title tag is missing.
(no comment)
Too short (5) ⚠️ Warning Title tag is 5 characters. Ideal length is ≥ 30.
Title tag is 5 characters (outside ideal range).
Title tag is too short.
Title tag is 5 characters. Ideal length is 30–60.
Ideal (45) ✅ Pass Your title tag is too long.
Title tag is 45 characters (ideal length).
Title tag is within the ideal length range.
Title tag is 45 characters.
Slightly too long (65) ⚠️ Warning Your title tag is too long.
Title tag is 65 characters (outside ideal range).
Title tag is too long.
Title tag is 65 characters. Ideal length is 30–60.
Too long (80) ❌ Fail Title tag is 80 characters. Ideal length is < 70.
Title tag is 80 characters. Ideal length is < 70.
Title tag is too long.
Title tag is 80 characters. Ideal length is 30–60.

Meta description length

Case Status Before After
Missing ❌ Fail Meta description is missing.
Meta description is missing.
Meta description is missing.
(no comment)
Too short (50) ⚠️ Warning Meta description is 50 characters. Ideal length is ≥ 120.
Meta description is 50 characters (outside ideal range).
Meta description is too short.
Meta description is 50 characters. Ideal length is 120–160.
Ideal (140) ✅ Pass Your meta description is too long.
Meta description is 140 characters (ideal length).
Meta description is within the ideal length range.
Meta description is 140 characters.
Slightly too long (200) ⚠️ Warning Your meta description is too long.
Meta description is 200 characters (outside ideal range).
Meta description is too long.
Meta description is 200 characters. Ideal length is 120–160.
Too long (260) ❌ Fail Meta description is 260 characters. Ideal length is < 240.
Meta description is 260 characters. Ideal length is < 240.
Meta description is too long.
Meta description is 260 characters. Ideal length is 120–160.

Tests

Added tests in ReportTest that check status, description and comment of the page results for every case of both rules, and that multibyte characters are counted once. Added a test in SeoProFieldtypeTest that the field instructions and character limits use the configured values. The existing tests pass unchanged.

Follow-up PRs

This is the first of a few related PRs on the report messages:

  • Unique title / meta description rules (Don't flag empty titles and meta descriptions as duplicates #669): pages with an empty title or meta description are currently counted as duplicates of each other (e.g. "3 pages with "" as the meta description."), in addition to the "missing" message of the length rules. Independent of this PR.
  • German translations (de, de_CH) (Revise German translations (de, de_CH) #670): a revised German translation of the add-on. Builds on this PR, as it translates the updated length rule messages and field instructions.

🤖 Generated with Claude Code

- Page descriptions now name the case (missing, too short, within the
  ideal range, too long) instead of falling back to "too long".
- Comments show the length and the ideal range (warn_min–pass_max)
  instead of repeating the description or naming the fail threshold.
- No comment when the value is missing, as the description says it all.
- Measure length with mb_strlen() so multibyte characters count once.
- Update en, de, de_CH and nl translations.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
helloDanuk and others added 3 commits September 17, 2026 16:10
The description already says the length is within the ideal range, so
the comment only gives the number of characters.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The instructions of the title and description fields had the default
limits hard-coded ("ideally less than 60 characters"), so they didn't
reflect a customized reports config and ignored the minimum.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…iption

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant