Invalid links: hrefs that do not parse as a URL
A malformed href is a link that goes nowhere, and javascript:void(0) is a button wearing a link costume. squirrel reports every href the parser rejected.
What an invalid link is
An invalid link is an <a href> whose value the parser could not turn into a URL, such as http://[invalid or an address with an unparseable host. It is a link that cannot go anywhere, usually produced by string concatenation or a template variable that resolved to something unexpected.
Several things that look wrong are not reported here. An empty href and non-HTTP schemes are skipped by the extractor, surrounding whitespace is trimmed, and a space inside a path is encoded during parsing rather than rejected. A javascript:void(0) click target is a real accessibility problem and a real reason to use a <button>, but it is not what this rule counts.
What squirrel checks
The rule runs on every crawled page and reports the links the parser flagged with an error while extracting them. It emits a single check named invalid-links:
- Pass when no link carries a parse error. Message:
No invalid link formats found. - Warn otherwise. Message:
Found 3 invalid link(s), with each href listed alongside the parser’s recorded error string. Severity warning, weight 2.
The classification comes from the parser rather than from this rule, so what counts as invalid is whatever the link extractor could not resolve against the page URL.
How to fix it
<button type="button" onclick="openDialog()">Open</button>Replace a click-target anchor with a button. For a genuinely malformed href, fix the template that produced it: an empty href="" usually means a variable that was not set, and a link with a stray space usually means the value came from unsanitised content.
| Rule ID | links/invalid-links |
| Category | Links |
| Scope | Per-page |
| Severity | warning |
| Weight | 2/10 |
Enable / disable
Disable this rule
[rules]
disable = ["links/invalid-links"]Disable all Links rules
[rules]
disable = ["links/*"]Enable only this rule
[rules]
enable = ["links/invalid-links"]enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.
Related rules
- links/broken-links: links that parse correctly and lead to an error page.
- links/anchor-text: links with no accessible name.
- a11y/link-text: the accessibility view of the same markup.
- url/special-chars: characters in a URL that need encoding.
Links findings ship in every audit next to the SEO, performance and agent experience rules. See Fix SEO issues with AI for how an agent works through a report.
References
Check your site
Run squirrel audit https://example.com and open the Links section of the report. Every unparseable href is listed with the error it produced. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.