# Make links available in HTML with href

- Check 08.06 · JavaScript and HTML rendering · Critical
- Source: https://checklist-seo-geo.com/en/javascript-html-rendering/make-links-available-html-href
- Make every internal link appear in the HTML as an a tag with a resolvable href, whatever your CMS, your framework and your router.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/javascript-html-rendering/make-links-available-html-href.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A crawler discovers a site's pages by following links, and it reliably recognizes only one form of link: an `<a>` tag with an `href` attribute containing a real address. This check consists of verifying that navigation, breadcrumbs, pagination, product lists and contextual links are `<a href>` elements, present in the initial HTML and not built later by JavaScript. Expected result: the number of internal links is roughly the same in the initial HTML and in the rendered DOM, and every link points to a URL that responds.

## Why it matters

Google sums it up this way: as a general rule, it can only crawl a link if it is an `<a>` element with an `href` attribute. It cannot reliably extract the URL from an `<a>` without an `href`, and the URL must resolve to an actual web address. A link inserted by JavaScript remains crawlable if it follows this markup, but it is only discovered after rendering.

This delay has three consequences:

- **Google** discovers the pages later, and does not discover them at all if rendering fails.
- **Generative engine crawlers**, which read the initial HTML without running JavaScript according to published observations, only see the links present in the server response. A menu built in JavaScript hides the rest of the site from them.
- **Internal linking** only passes signals through links the search engine has seen.

Fragment URLs raise a related problem: Google asks you not to use fragments (`#/produits`) to load different content, and to use the History API instead. To a crawler, `example.com/#/chaises` and `example.com/#/tables` are the same page.

## What it improves

- **Page discovery**: all linked pages are found at crawl time, without depending on rendering.
- **Internal linking**: link equity flows to strategic pages.
- **Visibility in generative engines**: their crawlers can move from one page to another and find deep pages. Indirect effect, with no guarantee of being cited.
- **Accessibility and usability**: a real link opens in a new tab, can be copied and shared, and works with the keyboard.
- **Rankings**: indirect effect, through better discovery and internal linking that is taken into account.

## How to check

**1. Compare the number of links.** In the initial HTML:

```bash
curl -s -L https://example.com/ | grep -o -i '<a [^>]*href="[^"#][^"]*"' | wc -l
```

Then in the browser console, on the displayed page:

```js
document.querySelectorAll('a[href]:not([href^="#"]):not([href^="javascript:"])').length
```

A gap of a few links (login button, widget) is normal. A gap of dozens of links means that the menu, the lists or the pagination are built by JavaScript.

**2. List the fake links in the rendered DOM**:

```js
console.table([...document.querySelectorAll('a:not([href]), a[href^="javascript:"], a[href="#"], [routerlink]:not(a), [onclick]:not(a):not(button)')]
  .map((el) => ({ balise: el.tagName, texte: el.textContent.trim().slice(0, 60) })));
```

**3. Run Lighthouse**, SEO category: the “Links are crawlable” audit (`crawlable-anchors`) lists the links whose `href` is not crawlable.

**4. Across the whole site**, compare in Screaming Frog the number of outlinks per page between a crawl in “Text Only” mode and a crawl in JavaScript mode.

## How to implement

### Before you start

What is crawlable, according to Google's documentation:

| Markup | Crawlable |
| --- | --- |
| `<a href="https://example.com/chaises">` | yes |
| `<a href="/chaises">` or `<a href="./chaises">` | yes |
| `<a href="/chaises" onclick="suivre('chaises')">` | yes, the `href` is enough |
| `<a routerLink="chaises">` with no rendered `href` | not reliable |
| `<span href="/chaises">` | not reliable |
| `<a onclick="aller('/chaises')">` | not reliable |
| `<a href="javascript:aller('chaises')">` | not reliable |
| `<a href="#/chaises">` (fragment routing) | no, same page for the crawler |

Rules to apply everywhere:

- every indexable page receives at least one `<a href>` link from another page;
- the `href` URL is the canonical version, with no redirect;
- the link text describes the destination (see [Use descriptive and varied anchor text](https://checklist-seo-geo.com/en/internal-linking/use-descriptive-varied-anchor-text));
- navigation links are in the initial HTML, not only after rendering.

Fake `onclick` links are fixed with the guide [Avoid links that rely solely on JS events](https://checklist-seo-geo.com/en/javascript-html-rendering/avoid-links-that-rely-solely-js-events). The general principles are in [Use crawlable HTML links](https://checklist-seo-geo.com/en/architecture-navigation/use-crawlable-html-links).

### Apache

Versions: Apache 2.4.

A single-page application that moves from fragment routing to History API routing needs the server to return the application for any URL that does not match a file. In the `.htaccess` file or the virtual host:

```apache
FallbackResource /index.html
```

This rule returns `200` for every URL, including those that do not exist: deal with this using [Check SPA HTTP status codes](https://checklist-seo-geo.com/en/javascript-html-rendering/check-spa-http-status-codes), or better, move to server-side rendering.

### Nginx

Versions: Nginx 1.18 and later, including the 1.30 stable branch.

Same need, in the `server` block:

```nginx
location / {
    try_files $uri $uri/ /index.html;
}
```

```bash
sudo nginx -t && sudo systemctl reload nginx
```

### WordPress

Versions: WordPress 6.4 and later (classic themes and block themes).

Menus (`Appearance > Menus` or the Site Editor, Navigation block), post lists, the breadcrumbs of SEO plugins and pagination produce `<a href>` links rendered in PHP. Problems come from:

- plugin mega menus that load their submenus through AJAX on hover: choose an option that renders them fully in the HTML;
- product or post grids filtered through AJAX that remove pagination: keep the links generated by `the_posts_pagination()` or WooCommerce pagination;
- page builder buttons configured with a JavaScript action instead of a link: fill in the button's link field.

### Shopify

Versions: Online Store 2.0 themes, Shopify admin, November 2026.

Liquid templates produce real links: use the URL objects rather than hand-written addresses.

```liquid
<nav aria-label="Breadcrumb">
  <a href="{{ routes.root_url }}">Home</a>
  {% if collection %}
    <a href="{{ collection.url }}">{{ collection.title }}</a>
  {% endif %}
</nav>

{% for product in collection.products %}
  <a href="{{ product.url }}">{{ product.title }}</a>
{% endfor %}
```

The main menu is set up in `Content > Menus` in the Shopify admin and displayed in the theme through the `linklists` object. Check that mega menu, filter or infinite scroll apps do not remove these links from the HTML.

### Wix

Versions: Wix Editor, Wix Studio and Velo, November 2026.

According to Wix's documentation, crawlable links are those in the site menu, hyperlinks in text, clickable elements (button, image) connected with the link tool, and collection URLs connected through a dataset. Other methods, such as navigation triggered by Velo code (`wixLocation.to()`), do not guarantee an `href` link. Every page must be reachable through at least one crawlable link.

### Laravel

Versions: Laravel 11 to 13, Livewire 3 and 4, Inertia 2 and 3.

In Blade, generate URLs with named routes:

```blade
<a href="{{ route('produits.show', $produit) }}">{{ $produit->nom }}</a>
```

- **Livewire**: `wire:navigate` is added to an `<a href>` and keeps the link crawlable; a `wire:click` that redirects is not a link.

```blade
<a href="{{ route('produits.index') }}" wire:navigate>All products</a>
```

- **Inertia**: the `<Link href="...">` component produces an `<a href>`. Without Inertia's server-side rendering, these links only exist after JavaScript runs: turn on SSR so that the navigation is in the initial HTML.

### Next.js

Versions: Next.js 15 and 16; the advice about server components and the layout applies to the App Router.

The `Link` component produces an `<a href>` and adds client-side navigation:

```tsx
import Link from 'next/link';

export default function Menu() {
  return (
    <nav aria-label="Main navigation">
      <Link href="/chaises">Chairs</Link>
      <Link href="/tables">Tables</Link>
    </nav>
  );
}
```

Render the menu in a server component or in the layout, not in a client component that fetches its list with `fetch` after loading. Keep `router.push()` for redirects after an action (form submission), not for navigation.

### Nuxt

Versions: Nuxt 3 and 4.

`<NuxtLink to="/chaises">` produces an `<a href="/chaises">`. For an external link, it also produces a full `<a href>`. Build menus from data fetched with `useFetch` or `useAsyncData`, which run on the server during the first render, and not in an `onMounted` hook, which only runs in the browser.

### Astro

Versions: Astro 5 to 7.

Astro produces HTML: write plain `<a href>` links. Island components loaded with `client:only` are not rendered on the server; do not put the main navigation in them.

### React, Vue, Angular and SvelteKit

- **React Router**: `<Link to="/chaises">` produces an `<a href>`. Use `createBrowserRouter` or `BrowserRouter`, not `HashRouter`.
- **Vue Router**: `<RouterLink to="/chaises">` produces an `<a href>`. Create the router with `createWebHistory()`, not `createWebHashHistory()`.
- **Angular**: put `routerLink` on an `<a>` element, which then receives an `href`. On a `<button>` or a `<div>`, `routerLink` does not create a link. Do not turn on fragment routing (`withHashLocation()`).

```html
<a routerLink="/chaises" routerLinkActive="actif">Chairs</a>
```

- **SvelteKit**: write `<a href>` links; the router intercepts them automatically.

In all these cases, without server-side rendering or pre-rendering, the links only exist after JavaScript runs. See [Prefer SSR or SSG for critical content](https://checklist-seo-geo.com/en/javascript-html-rendering/prefer-ssr-ssg-critical-content-if-relevant).

## Common mistakes

- **Building the menu in JavaScript from an API**: the site looks navigable to visitors but is not for crawlers that read the initial HTML.
- **Fragment routing**: `#/produits/12` is not a separate URL for a search engine. Switch to the History API.
- **`href="#"` with a click handler**: the crawler sees a link to the page itself.
- **Links to redirected or non-canonical URLs**: they waste crawling. Point directly to the final URL.
- **Submenus loaded on hover**: the crawler does not hover over anything; the submenu must be in the HTML.
- **Pagination replaced by a button**: page 2 and the following pages are no longer discovered.
- **Relying on the sitemap**: it helps discovery, but does not replace internal linking, which also indicates the relative importance of pages.

## Frequently asked questions

### Does Google follow links added by JavaScript?

Yes, Google follows a link added by JavaScript if it is an a tag with an href attribute containing a real URL, but it only discovers it after the page has been rendered. If rendering fails or is delayed, the linked page has to wait. Generative engine crawlers, which do not run JavaScript according to published observations, do not see these links at all.

### Is a link with onclick but no href followed?

No, not reliably: Google says it cannot properly extract the URL from an a tag without an href attribute. An element that navigates only through an onclick handler is not a link for a crawler. Add an href pointing to the destination; you can keep the handler for analytics tracking or client-side navigation.

### Are URLs with a # indexed separately?

No, a URL with a fragment, such as example.com/#/chaises, is treated as the page example.com/. Google asks you not to use fragments to load different content and recommends the History API, which gives each view a real URL. In-page anchors pointing to a section, such as #livraison, remain useful for readers, but do not create a separate page.

### Do internal links need absolute URLs?

No, a relative URL such as /chaises or ./chaises is just as crawlable as an absolute URL, according to Google's documentation. What matters is that the href resolves to a real address that returns 200 and that it points to the canonical version of the page. Absolute URLs remain preferable in sitemaps, canonicals and hreflang tags.

## Resources

- [Google Search Central: Make your links crawlable](https://developers.google.com/search/docs/crawling-indexing/links-crawlable)
- [Google Search Central: Understand the JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics)
- [MDN: the a element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a)
- [MDN: History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)
- [Wix: SEO best practices, crawlable links](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/best-practices/seo-best-practices)

Next steps: [Avoid links that rely solely on JS events](https://checklist-seo-geo.com/en/javascript-html-rendering/avoid-links-that-rely-solely-js-events), [Check dynamic pagination](https://checklist-seo-geo.com/en/javascript-html-rendering/check-dynamic-pagination) and [Detect orphan pages](https://checklist-seo-geo.com/en/architecture-navigation/detect-orphan-pages).
