Inspection Rules
The module runs 15 inspections covering broken links, SEO best practices, and accessibility. To disable any rule, add it to skipInspections in your config.
Rule Categories
| Category | Rules |
|---|---|
| Broken Links | no-error-response, missing-hash, redirects |
| SEO | no-uppercase-chars, no-underscores, trailing-slash, no-whitespace, no-non-ascii-chars |
| URL Structure | absolute-site-urls, no-baseless, no-double-slashes, no-duplicate-query-params |
| Accessibility | link-text, no-missing-href, no-javascript |
Disabling Rules
To disable any rule, add it to skipInspections:
export default defineNuxtConfig({
linkChecker: {
skipInspections: ['rule-name']
}
})Available Rules
Rules are based on the URL structure best practices for Google.
| Rule | Description |
|---|---|
absolute-site-urls | Checks for absolute links that are internal. |
link-text | Ensures link text is descriptive and meaningful. |
missing-hash | Checks for missing hashes in internal links. |
no-baseless | Checks for document relative links. |
no-double-slashes | Checks for double slashes in URLs. |
no-duplicate-query-params | Checks for duplicate query parameters in URLs. |
no-error-response | Checks for error responses (4xx, 5xx) on links. |
no-javascript | Checks for JavaScript links. |
no-missing-href | Ensures that a tags have an href attribute. |
no-non-ascii-chars | Checks for non-ASCII characters. |
no-underscores | Checks for underscores. |
no-uppercase-chars | Checks for uppercase characters. |
no-whitespace | Checks for whitespace. |
redirects | Warns when links respond with a redirect. |
trailing-slash | Checks for trailing slashes on internal links. |
absolute-site-urls
Checks for absolute links that are internal
Using relative paths is recommended as it makes your site more portable and easier to maintain.
<NuxtLink to="https://example.com/about">my page</NuxtLink><NuxtLink to="/about">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'absolute-site-urls'
],
},
})link-text
Ensures link text is descriptive and meaningful.
Descriptive link text provide improved accessibility, allowing screen readers to better understand the context of the link. It flags non-descriptive link text such as "click here", "click this", "this", "learn more", "go", "here", "start", "right here", "more", and similar.
<NuxtLink to="/about">click here</NuxtLink><NuxtLink to="/about">About</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'link-text'
],
},
})missing-hash
Checks for missing Document Fragments for internal links.
Having valid hashes ensures that users are navigated to the correct section of the page, improving the user experience and accessibility.
<div id="valid-anchor"></div>
<NuxtLink to="#valid">my page</NuxtLink><div id="valid"></div>
<NuxtLink to="#valid">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'missing-hash'
],
},
})no-baseless
Document relative links are valid but can cause SEO maintenance issues when moving around your content.
It's recommended to use root relative links to avoid these issues.
<NuxtLink to="link">my page</NuxtLink><NuxtLink to="/link">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-baseless'
],
},
})no-double-slashes
Checks for double slashes in URLs.
Double slashes in URLs can cause canonicalization issues and can lead to duplicate content.
<NuxtLink to="/link//">my page</NuxtLink><NuxtLink to="/link/">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-double-slashes'
],
},
})no-duplicate-query-params
Checks for duplicate query parameters in URLs.
Duplicate query parameters can cause issues with caching and can lead to duplicate content.
<NuxtLink to="/link?param=1¶m=2">my page</NuxtLink><NuxtLink to="/link?param=1">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-duplicate-query-params'
],
},
})no-error-response
Checks for error responses (4xx, 5xx) on links.
Ensuring that links do not lead to error responses improves the user experience and improves
your sites crawlability. For internal links, the module will suggest similar pages when it finds a match. Checking external links requires fetchRemoteUrls: true.
<NuxtLink to="/broken-link">my page</NuxtLink><NuxtLink to="/valid-link">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-error-response'
],
},
})no-javascript
Checks for JavaScript links.
JavaScript links provide poor user experience as they override the default browser behavior.
It's recommended to use a <button type="button"> if you need an on click event.
<a href="javascript:doSomething()">my page</a><button type="button" @click="doSomething()">my page</button>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-javascript'
],
},
})no-missing-href
Ensures that links have an href attribute.
Links need an href attribute for accessibility and usability. If you need an anchor that doesn't navigate, use a <button> instead
or the role="button" attribute.
<a>my page</a><a href="/link">my page</a>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-missing-href'
],
},
})no-non-ascii-chars
Checks for non-ASCII characters in URLs.
Non-ASCII characters can cause issues with encoding and can lead to broken links.
<NuxtLink to="/my-ページ">my page</NuxtLink><NuxtLink to="/my-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-non-ascii-chars'
],
},
})no-underscores
Checks for underscores in URLs.
Underscores are not recommended in URLs as they can cause issues with readability and SEO.
<NuxtLink to="/my_page">my page</NuxtLink><NuxtLink to="/my-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-underscores'
],
},
})no-uppercase-chars
Checks for uppercase characters in URLs.
Uppercase characters are not recommended in URLs as they can cause issues with readability and SEO.
<NuxtLink to="/MyPage">my page</NuxtLink><NuxtLink to="/my-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-uppercase-chars'
],
},
})no-whitespace
Checks for whitespace in URLs.
Whitespace in URLs can cause issues with encoding and can lead to broken links.
<NuxtLink to="/my page">my page</NuxtLink><NuxtLink to="/my-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'no-whitespace'
],
},
})redirects
Warns when a link responds with a redirect: 301, 302, 303, 307 or 308. The suggested fix is the Location target.
The rule runs in development and in the build scan. A redirect from routeRules or from a server middleware counts.
Redirects use up your crawl budget and increase loading times. It's recommended to link directly to the final URL when possible.
<!-- Links to a URL that redirects to /new-page -->
<NuxtLink to="/old-page">my page</NuxtLink><NuxtLink to="/new-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'redirects'
],
},
})trailing-slash
Checks that internal links all either have or don't have a trailing slash depending on your configuration.
Inconsistent trailing slashes can cause issues with canonicalization and can lead to duplicate content.
The behavior depends on the siteConfig.trailingSlash setting. The example below assumes the default setting, with trailing slashes disabled.
<!-- trailing slashes disabled (default) -->
<NuxtLink to="/my-page/">my page</NuxtLink><NuxtLink to="/my-page">my page</NuxtLink>export default defineNuxtConfig({
linkChecker: {
skipInspections: [
'trailing-slash'
],
},
})A directory index in public/ always takes a trailing slash, whatever siteConfig.trailingSlash says. For public/demo/index.html, link to /demo/. The page resolves its relative assets against /demo/, and most static hosts redirect /demo/index.html to /demo/.
If nitro.prerender.crawlLinks is on, the crawler renders /demo/ as a Nuxt page and fails with a 404. To skip it, add '/demo/**': { prerender: false } to routeRules.