Skip to content

refactor(field): remove the Shortlink field - #72

Merged
Fredxd merged 1 commit into
AppoloDev:mainfrom
Vondry:refactor/remove-shortlink-field
Oct 24, 2026
Merged

Fredxd merged 1 commit into
AppoloDev:mainfrom
Vondry:refactor/remove-shortlink-field

Conversation

@Vondry

@Vondry Vondry commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

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

  • In this extension: assets/seo/seo.js copied the input into the field's JSON, and nothing ever read it back. No route, redirect, listener, Seo method or meta tags template reads shortlink, in any release.
  • In the original Bolt 3 extension (bobdenotter/seo), the field was added in 2015 without an implementation. In Usage of the field "shortlink" ? bobdenotter/seo#20 ("Usage of the field 'shortlink'?", 2016), the author replied: "This feature wasn't implemented I think. One of those things i figured would be handy to have, but I never got around to implementing it yet." The issue is still open, and the last comment (2020) suggests removing the field.
  • Here: this package copied the field, its template block and its translations in its first commits (2020-11-18). Later commits only translated it into more languages.

Changes

  • templates/seo.html.twig: removed the seo_shortlink block, its {{ block() }} call, and the shortlink key in the default JSON.
  • assets/seo/seo.js: removed #seofields-shortlink from 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.
  • New test (tests/Twig/SeoFieldScriptTest.php): seo.js calls addEventListener() 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 shortlink key in their SEO JSON keep it. seo.js re-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-shortlink input. A browser that still has the old seo.js cached throws Cannot 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 new seo.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-install and post-update scripts run extensions:configure, which calls Extension::install() and copies assets/ to public/assets/.

Verified

  • vendor/bin/phpunit: 121 tests pass (2 new). rector, ecs, phpstan, composer validate --strict and bin/lint-xliff translations pass.
  • On a Bolt 6 install, with the new seo.js the editor loads without JS errors and has no Shortlink input. Editing title, canonical, robots and og:type updates the saved JSON.
  • With the old seo.js and 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

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.
@Vondry

Vondry commented Oct 24, 2026

Copy link
Copy Markdown
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.

@Fredxd
Fredxd merged commit c510710 into AppoloDev:main Oct 24, 2026
21 checks passed
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.
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.

2 participants