Repository navigation
refactor(field): remove the Shortlink field - #72
Merged
Merged
Conversation
The Shortlink (alias) input promised to "create an alias or shortlink to this record", but nothing has ever read the value. No route, redirect or template uses it. The field came from the original Bolt 3 extension (bobdenotter/seo), where it was never implemented either (bobdenotter/seo#20), and it was copied along with the rest of the field in 2020. This removes the input, its default key, the matching entry in seo.js, and its three translation units from all 15 locales. Values already stored in a record's SEO JSON are kept and ignored, like before. seo.js adds a listener to every input it looks up without a null check, so the template and the script must agree on the input ids. A new test renders the field and checks that every `#seofields-*` id the script uses is there.
Contributor
Author
|
Note that after all these PRs are merged, we should also update the screenshot in README, because there is a lot of changes to the UI since the screenshot was taken. |
Vondry
added a commit
to Vondry/bolt-seo
that referenced
this pull request
Oct 24, 2026
AppoloDev#72 removed the Shortlink input from seo.html.twig and seo.js, but the jsdom tests in tests/js/seo.test.mjs build their own copy of the field's markup and still rendered #seofields-shortlink and expected typing in it to be persisted. seo.js no longer listens to that input, so `npm test` failed on "typing in the SEO shortlink input persists it". SeoFieldScriptTest didn't catch this: it checks that every input the script uses is rendered by the template, not that the JS test fixture matches the template. Remove shortlink from the fixture and the per-input persistence tests, and add a test that a shortlink value already stored in a record's SEO JSON is kept on the next save, as AppoloDev#72 promised.
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR removes the "Shortlink (alias)" input from the SEO field. Its help text said "Use this to create an alias or shortlink to this record", but the value has never been used. It was only saved into the field's JSON.
Why it did nothing
assets/seo/seo.jscopied the input into the field's JSON, and nothing ever read it back. No route, redirect, listener,Seomethod or meta tags template readsshortlink, in any release.Changes
templates/seo.html.twig: removed theseo_shortlinkblock, its{{ block() }}call, and theshortlinkkey in the default JSON.assets/seo/seo.js: removed#seofields-shortlinkfrom the inputs the script listens to. This has to ship together with the template change, see below.translations/*.xlf: removed the three units that only this field used ("Shortlink", "alias" and its help text) from all 15 locales.tests/Twig/SeoFieldScriptTest.php):seo.jscallsaddEventListener()on every input it looks up, with no null check. If the template stops rendering one of them, the script throws while it starts, and the inputs after it stop saving. The test renders the whole field, with the keywords field both disabled and enabled, and checks that every#seofields-*id the script uses is rendered exactly once. It fails if the template block is removed without the script line.Existing data
Records that already have a
shortlinkkey in their SEO JSON keep it.seo.jsre-saves whatever keys are already in the JSON, so the value stays, still unused. New records no longer get the key.Upgrade note: hard-refresh the admin
The new template has no
#seofields-shortlinkinput. A browser that still has the oldseo.jscached throwsCannot read properties of null (reading 'addEventListener')when the editor opens. With the old script, title and description still save, but changes to Canonical Link, Meta Robots Tag and Open Graph Type are not saved. This lasts until the browser loads the newseo.js, because the script URL has no version to force a fresh download. After upgrading, editors should hard-refresh the Bolt admin once (Ctrl+Shift+R, or Cmd+Shift+R on a Mac).Normal deploys update the file itself: Bolt's composer
post-installandpost-updatescripts runextensions:configure, which callsExtension::install()and copiesassets/topublic/assets/.Verified
vendor/bin/phpunit: 121 tests pass (2 new).rector,ecs,phpstan,composer validate --strictandbin/lint-xliff translationspass.seo.jsthe editor loads without JS errors and has no Shortlink input. Editing title, canonical, robots and og:type updates the saved JSON.seo.jsand the new template, the error above happens, and canonical, robots and og:type are not saved. That's why the upgrade note is needed.Related
allowblock #71 removes the unusedallow:block inconfig/config.yaml, which also listedshortlink.allowblock #71.