Skip to content

🐛 Use --canonical and --base from new staticalize - #1255

Merged
taras merged 2 commits into
v4from
tm/canonical-via-staticalize
Sep 30, 2026
Merged

taras merged 2 commits into
v4from
tm/canonical-via-staticalize

Conversation

@taras

@taras taras commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Motivation

#1248 pointed the production --base at https://frontside.com/effection so
that the canonical url would be right, but it also changed every self-referencing url including the sitemap.

<!-- effection.netlify.app/sitemap.xml -->
<loc>https://frontside.com/effection/docs</loc>

Approach

Added --base and --canonical URL to staticalize@0.3.1.

This allows to rewrite all local URLs to URLs with prefix and canonical to the remote URL.

Related

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/effection@1255

commit: a0e958e

@codspeed

codspeed Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing tm/canonical-via-staticalize (a0e958e) with v4 (ff2be9a)

Open in CodSpeed

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Deploy Preview Ready!

#1248 pointed the production `--base` at frontside.com/effection to get the
canonical right. That moved every other url with it, including the sitemap,
and frontside.com prefixes `/effection` onto a proxied sitemap whose entries
now already carried it. 519 urls 404'd and its deploys have failed since.

staticalize 0.3.1 separates the two. `--base` is where the bytes are again,
so the Netlify copy is readable on its own and its sitemap says so;
`--canonical` is the address readers arrive at, and only the urls that name
the page follow it.

That makes the site's own copy of the idea redundant. `canonical()` had been
rebasing onto a configured origin, which is exactly what staticalize now
does, so it is gone along with the `base` field and the `--base` option —
which also ends this project having two different flags by that name. What
`app.html.tsx` needs is the url of the page being served, so that is what it
asks for: `currentUrl()`, a plain operation rather than a member of the api.
Calling it `canonical` would have named it after what the crawl does to it.

Dropping the member also drops the `Api<UrlApi>` annotation, which only
existed because a member reached back through the api for another.

Verified against the real site: canonical, og:url and both hreflang
alternates name frontside.com; og:image and the sitemap name Netlify; the
sitemap has no doubled paths; and llms.txt still names the published site,
which is what #1248 wanted.

0.3.1 also restored the default for `--retries`, so the flag 0.3.0 forced us
to pass goes away with it.
@taras
taras force-pushed the tm/canonical-via-staticalize branch from de50809 to 688df50 Compare September 28, 2026 22:16
@taras taras changed the title 🐛 Name the published site with --canonical instead of --base 🐛 Use --canonical and --base from new staticalize Sep 28, 2026
@taras
taras requested a review from cowboyd September 30, 2026 00:18
Deno's minimum dependency age refuses a jsr version for its first 24 hours,
which is why the pagefind route sat on 0.2.7 while the deploy moved on: the
comment on that pin says pinning it forward would make the dev server wait
out the policy on the day of a release.

npm resolution is not subject to it, so both callers can name the version
the deploy uses. `npm:staticalize@0.3.1` is the same program — the package
publishes a `bin` rather than a `/cli` export, so the specifier loses its
subpath.

Verified both callers against the running site: the deno task and the exact
command the pagefind route execs each crawled 505 pages and 21 assets with
no errors.
@taras
taras merged commit 88aec4f into v4 Sep 30, 2026
19 checks passed
@taras
taras deleted the tm/canonical-via-staticalize branch September 30, 2026 11:48
taras added a commit to thefrontside/graphgen that referenced this pull request Sep 30, 2026
frontside.com proxies this site and serves the same pages, so the two
origins are duplicates of each other. Nothing said which one is the
original: the docs emitted no canonical at all, and the deploy staticalized
with `--base=https://graphgen-data.netlify.app`, so every link and every
sitemap entry named the hosting url rather than the one readers visit.

Two identical sites and no signal is how they end up competing for the same
searches instead of counting as one page. Neither origin has a robots.txt
either, so nothing else settles it.

The docs pages now name the url they are read at, built from the request so
that a local crawl still names localhost. staticalize 0.3.1 rewrites it
onto `--canonical` while the rest of the build stays on `--base`, so the
Netlify copy remains readable on its own and its sitemap still says so.
Only `routes/docs/[...slug].tsx` needs it: `index.tsx` is a 307 with no
markup, and `[name].tsx` is not in the sitemap.

staticalize comes from npm rather than jsr. Deno's minimum dependency age
refuses a jsr version for its first 24 hours, and both deploy jobs run this
task, so a jsr specifier would fail every deploy on the day of a release.
npm resolution is not subject to it. The package publishes a `bin` rather
than a `/cli` export, so the specifier loses its subpath.

0.3.1 also restored the default for `--retries`, so the flag 0.3.0 forced us
to pass goes away with it.

thefrontside/effection#1255 and thefrontside/interactors#333 make the same
move; `fix-static-css.ts` only rewrites Twind css in html and is unaffected.

This branch was successfully deployed

1 active deployment
Preview — a0e958e9 Deployed Sep 30, 2026 by taras via deploy-preview #1411
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