Skip to content

🐛 Leave an alternate that is not a language variant on --base - #23

Open
taras wants to merge 1 commit into
mainfrom
alternate-hreflang
Open

taras wants to merge 1 commit into
mainfrom
alternate-hreflang

Conversation

@taras

@taras taras commented Sep 28, 2026

Copy link
Copy Markdown
Member

Motivation

rel=alternate covers two unrelated things, and #22 treated them as one.

With hreflang, it is this page in another language:

<link rel="alternate" href="…" hreflang="en">

That is a claim about the page, so it belongs with the canonical url.

Without it, it points at a separate file:

<link rel="alternate" type="application/rss+xml" href="…/feed.xml">
<link rel="alternate" type="text/plain" href="…/llms.txt">

A file lives where the build is served. Sending those to --canonical would
publish a feed url on a site that does not host the feed.

Nothing has hit this. Effection writes both of those relatively, and staticalize
only rewrites urls that start with the crawl origin, so it never touched them —
I noticed it while reading the output of thefrontside/effection#1255 rather than
from a failure.

Approach

names() splits the two cases. hreflang is the whole test, since that is what
distinguishes a translation of this page from a different representation of it:

if (rel.includes("alternate")) {
  return Boolean(element.properties?.hrefLang);
}

hrefLang is how hast spells the attribute; I checked rather than assumed.

Tests

Extended the existing split test with a feed alternate, so one case now asserts
both halves of the rule: alternate[hreflang] lands on --canonical, and
alternate[type=application/rss+xml] on --base.

I confirmed the assertion actually catches the old behaviour by reverting
names() and re-running:

sends urls that name the page to --canonical, and the rest to --base ... FAILED

'<link rel="alternate" type="application/rss+xml" href="https://frontside.com/interactors/feed.xml">'
  doesn't contain the expected item
'<link rel="alternate" type="application/rss+xml" href="https://interactors.netlify.app/feed.xml">'

All 33 steps pass with the fix.

`rel=alternate` covers two unrelated things. With `hreflang` it is this page
in another language, which is a claim about the page and belongs with the
canonical url. Without it — `type=application/rss+xml`, a `text/plain`
llms.txt — it points at a separate file, and a file lives where the build is
served.

#22 sent both to `--canonical`, so a site that writes its feed link
absolutely would have published a feed url on a site that does not host the
feed. Nothing hit it: Effection writes those two relatively, and staticalize
only rewrites urls that start with the crawl origin.
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