Insights

A href SEO: how HTML links help Google and AI find your pages.

A href SEO is the practice of building every link as a real HTML anchor element with a crawlable href attribute, descriptive anchor text and the right rel value. Google discovers pages and judges relevance through those links, and AI search depends on them too. Links that only work through JavaScript may never be found.

Plan a strategic call
Our SEO approach

SEO

14 min read

Most link problems are invisible to the people who build the site. The menu works, the buttons respond and every page opens when you click. But a crawler does not click. It reads the HTML, looks for <a> elements with an href attribute and follows those. When a link exists only as a JavaScript click handler, a styled <div> or a # placeholder, the page behind it can stay undiscovered, and every signal that link could have carried is lost.

This guide covers the HTML side of link SEO. It is built on Google Search Central’s own link best practices and on what we see when we audit and build websites. (Looking for Ahrefs, the SEO platform with the similar name? Read our guide to Ahrefs instead.)

What does a href mean in SEO?

<a href> is the HTML code for a link. The <a> element (the anchor element) creates the link, the href attribute (short for hypertext reference) holds the destination URL, and the text between the tags is the anchor text people click. For SEO, it is the one link format Google reliably crawls.

<a href="https://viralistic.nl/seo">our SEO approach</a>

Google states that it uses links “as a signal when determining the relevancy of pages and to find new pages to crawl.” That gives every <a href> two jobs. It is a path that lets Googlebot discover a URL, and it is context: the anchor text and the words around it tell Google what the destination is about. Links also feed canonicalization, because Google consolidates signals such as links to duplicate URLs into the version it picks as canonical.

Other attributes refine the link. rel describes your relationship with the destination, target controls where it opens and hreflang names the language of the linked page. Each one is covered below.

Google can generally only crawl a link if it is an <a> element with an href attribute that resolves to a real URL. Links in other formats are mostly not parsed. Google also says it cannot reliably extract URLs from anchor elements without an href, or from other elements that only act as links through script events.

<!-- Google can crawl these -->
<a href="https://example.com/shoes">Shoes</a>
<a href="/products/shoes">Shoes</a>
<a href="/products/shoes" onclick="trackClick('shoes')">Shoes</a>

<!-- Google cannot reliably crawl these -->
<a onclick="goTo('/products/shoes')">Shoes</a>
<span href="/products/shoes">Shoes</span>
<a href="javascript:goTo('shoes')">Shoes</a>
<div onclick="location.href='/products/shoes'">Shoes</div>

The difference is simple. In the first group the destination sits in the href, where a crawler can read it without running any code. In the second group the destination only appears when a script runs after a click.

An onclick handler is fine as an addition, not as a replacement. Track clicks, open a menu or animate a transition with JavaScript, but keep a real URL in the href so the link still works for crawlers and for anyone whose script fails to load. This matters most on single-page apps, where frameworks sometimes render navigation as buttons or as elements with a router attribute. Google’s JavaScript SEO guidance asks for real <a href> links and for the History API instead of fragments for routing. Software companies whose marketing site runs on a single-page framework are especially exposed, as our guide to SEO for software companies explains.

Always check the rendered HTML, not your component code. The URL Inspection tool in Google Search Console shows the HTML exactly as Googlebot rendered it.

A fragment such as #pricing jumps to a section on the same page. That is useful for readers, but Google generally does not support fragments as separate URLs. Do not use href="#" as navigation with the real destination hidden in a script, and do not load different content behind fragment URLs. If a view deserves to rank, it deserves its own path.

How should you write anchor text?

Good anchor text is descriptive, reasonably concise and relevant to both the page it sits on and the page it points to. Google calls “click here”, “read more”, “website” and “article” too generic, because they say nothing about the destination.

<!-- Too generic -->
Want to show up in AI answers? <a href="/help/astro/ai-search">Click here</a>.

<!-- Descriptive -->
Read our guide on how to <a href="/help/astro/ai-search">get cited by AI search</a>.

The rules from Google’s guidance that hold up in practice:

  • Write naturally. Cramming keywords into anchor text is keyword stuffing, which violates Google’s spam policies.
  • Mind the sentence around the link. The words before and after a link give it context.
  • Do not chain links next to each other. Space them out so each one keeps its own context.
  • Never leave a link empty. For image links, Google uses the image’s alt text as the anchor text, and for an empty <a> element it can fall back on the title attribute.

We prefer varied, accurate anchors over repeating one exact phrase on every page. It reads naturally, it describes each destination better and it stays far away from anything that looks like stuffing.

Internal links are how Google and your visitors find their way through your site. Google’s guidance is direct: “Every page you care about should have a link from at least one other page on your site.” A page that nothing links to (an orphan page) depends on your sitemap to be found, and it gets none of the context that internal anchor text provides.

What we check in an internal linking audit:

  • Every important page is reachable through plain <a href> links, within a few clicks of the homepage.
  • Navigation, footers and breadcrumbs render as HTML links, not as script-driven menus.
  • Links point straight to the final, canonical URL. Google recommends linking to the canonical URL rather than a duplicate, and every redirect in between is a detour.
  • Related articles link to each other in the body text, where the anchor text carries the most context.

On the Astro sites we build, links are rendered into static HTML at build time, so crawlers see them without running any JavaScript. Our Astro SEO guide shows how titles, canonicals and internal links work on those sites.

When should you use nofollow, sponsored and ugc?

Use the rel attribute when you need to tell Google something about your relationship with the page you link to. For ordinary links you vouch for, add nothing. Google recognises three values for this:

rel valueUse it forExample
sponsoredAds, paid placements and other compensated linksA paid review or an affiliate link
ugcLinks inside user-generated contentComments and forum posts
nofollowLinks you do not want to endorse, when the other values do not fitCiting a source you do not trust

Google introduced sponsored and ugc in September 2019 and has treated all three values as hints, not strict commands, ever since. For crawling and indexing, nofollow became a hint on 1 March 2020. You can combine values, such as rel="ugc nofollow", and existing nofollow links on paid placements remain acceptable, although Google prefers sponsored.

<a href="https://partner.example.com/offer" rel="sponsored">Partner offer</a>
<a href="https://visitor-site.example.com" rel="ugc nofollow">Visitor's website</a>

Two mistakes we see often:

  1. Adding nofollow to every external link. Google advises using nofollow only when you do not trust the source, not for every external link. Linking out to good sources is normal and can support trust, for example when you cite where a fact comes from.
  2. Adding nofollow to your own internal links. Internal links are how your own pages get found. For pages within your own site that crawlers should skip, Google points to a robots.txt disallow rule instead.

On our own site, partner links carry rel="sponsored noopener" automatically, so nobody has to remember it link by link.

target="_blank" opens a link in a new tab. It is a user experience choice, not a ranking signal: Google’s link guidance does not mention it, and the rel values Google reads for SEO are sponsored, ugc and nofollow.

rel="noopener" is a security instruction for the browser. It stops the new tab from getting access to your page through window.opener. According to MDN, modern browsers already apply that behaviour to target="_blank" links automatically, so adding noopener yourself is a harmless safeguard. rel="noreferrer" goes further and hides the referring page, which means the site you link to usually sees the visit as direct traffic instead of a referral from you.

<a href="https://example.com/annual-report.pdf" target="_blank" rel="noopener">
  Annual report (PDF, opens in a new tab)
</a>

Use new tabs sparingly. W3C accessibility guidance recommends warning people in advance when a link opens a new window, so nobody loses their place.

Absolute or relative URLs: which is better for SEO?

For ordinary links, both work. Google’s own examples of crawlable links include absolute URLs (https://example.com/shoes) and relative paths (/products/shoes). Relative internal links are shorter and survive a domain change. Absolute links stay unambiguous when your content is copied or syndicated elsewhere.

The rule changes for the elements in your <head>:

  • Canonical: Google recommends absolute URLs in rel="canonical". Relative paths are supported, but they can cause problems, for example when a test site gets crawled.
  • Hreflang: alternate URLs must be fully qualified, including https://. Google gives https://example.com/foo as correct and //example.com/foo or /foo as wrong.

Whatever you choose, be consistent. Pick one host (with or without www), one protocol (https) and one trailing slash convention, and link to exactly that version every time. Viralistic sites, for example, use URLs without a trailing slash, and every internal link follows that pattern. Each mismatch costs a redirect.

Hreflang and canonical look like links, but they live in <link> elements in the <head>, not in <a href> links in the page body. They tell Google how pages relate to each other rather than giving visitors something to click.

Hreflang

Google accepts three equivalent ways to mark language and region versions of a page: <link rel="alternate" hreflang> elements in the head, HTTP headers or your XML sitemap. Each version must list itself and every other version, the annotations must point both ways (Google ignores them otherwise), and an x-default catches everyone whose language you do not serve.

<link rel="alternate" hreflang="en" href="https://viralistic.nl/seo">
<link rel="alternate" hreflang="nl" href="https://viralistic.nl/nl/seo">
<link rel="alternate" hreflang="de" href="https://viralistic.nl/de/seo">
<link rel="alternate" hreflang="x-default" href="https://viralistic.nl/seo">

HTML also allows an hreflang attribute on a normal <a href>, for example in a language switcher. That is valid HTML and describes the language of the linked page, but it is not one of the three methods Google lists for localized versions. Our own site uses both: the language switcher carries hreflang on its <a> links, and the head carries the full set of <link rel="alternate"> elements with absolute URLs and an x-default. The head is what tells Google which version to show.

Canonical

A rel="canonical" link element tells Google which URL you prefer when the same content is reachable at several addresses, for example with tracking parameters. Google only accepts it in the <head>, recommends an absolute URL and advises a self-referencing canonical on the preferred page itself. If you use hreflang, each canonical should point to a page in the same language. And keep it stable: set the canonical in the HTML and do not let JavaScript change it.

<link rel="canonical" href="https://viralistic.nl/seo">

Your canonicals and your internal links should agree. If the canonical names one URL and your menu links to another, you are giving Google two answers to one question.

No single href tool catches everything, so we combine a few. We use SEO tools such as Ahrefs in our audits, alongside Google’s own data. Each tool sees your links from a different angle.

ToolWhat it showsGood to know
Google Search ConsoleURL Inspection shows the HTML Googlebot rendered; the Links report shows your most-linked pages and common link textFree, and the only view from Google itself
Screaming Frog SEO SpiderCrawls your site like a search engine: broken links, redirect chains, anchor text, nofollow, canonicals and hreflangFree for up to 500 URLs per crawl; JavaScript rendering needs a paid licence
Ahrefs Site AuditCrawls your site and flags more than 170 technical SEO issues, including link problemsIncluded in Ahrefs Free as of October 2026; more in our Ahrefs guide
Semrush Site AuditInternal link issues such as broken links, nofollow internal links and missing anchor textPart of the Semrush platform
W3C Link CheckerChecks the links on a page, or part of a site, for errors and redirectsFree, simple, no account needed
Browser developer toolsInspect an element to see whether a link is a real <a href>Compare view source with the rendered page

Start with Search Console and one crawler. Fix broken links and redirect chains first, then look at anchor text and orphan pages. If Ahrefs is your crawler, our guide on how to use Ahrefs walks through Site Audit step by step.

AI search runs on the same links. Google says its generative AI features, such as AI Overviews and AI Mode, are rooted in its core Search ranking and quality systems, and it asks site owners to keep content crawlable. Those features retrieve pages from the Search index and fan a question out into related queries. A page that is hard to discover is hard to retrieve.

Other AI crawlers are less capable than Googlebot. In a December 2024 study with MERJ, Vercel found that none of the major AI crawlers it measured rendered JavaScript, including OpenAI’s GPTBot, OAI-SearchBot and ChatGPT-User, Anthropic’s ClaudeBot and PerplexityBot. Google’s Gemini was the exception, because it uses Googlebot’s infrastructure. The ChatGPT and Claude crawlers also spent more than a third of their fetches on 404 pages. Crawler behaviour changes over time, but the lesson holds: links that only exist after JavaScript runs may be invisible to these systems, and broken links waste the attention they do give you.

What that means in practice:

  • Render your main content and navigation as HTML, on the server or at build time.
  • Keep every important link a plain <a href> with a real URL.
  • Fix broken internal links and keep redirects to a single hop.
  • Use descriptive anchor text, so any reader of the page, human or machine, knows where a link goes.

Our guide on how to get cited by AI search covers the rest of the picture, from crawler access to consistent facts. If you are comparing providers, our overview of GEO services shows what good AI visibility work includes.

A quick a href SEO checklist

  • Every link is an <a> element with an href that resolves to a real URL.
  • No navigation depends on onclick, javascript: URLs or # placeholders.
  • Anchor text is descriptive, concise and never empty, and image links have alt text.
  • Every page you care about has at least one internal link pointing to it.
  • Internal links go straight to the canonical URL, without redirects.
  • sponsored on paid and affiliate links, ugc on user content, nofollow only where you do not vouch for the destination.
  • New tabs only where they help the reader, with noopener and a visible notice.
  • Canonical and hreflang sit in the <head> with absolute URLs.
  • A crawl with a link checker shows no broken links and no redirect chains.

How we help

Links are where technical SEO and good writing meet, and they tend to break quietly during redesigns and migrations. Viralistic reviews link structure as part of our SEO and AI search work. We crawl your site, check what Google and AI crawlers can actually reach, and fix the structure, anchors and rel values that hold your pages back. When we build a site in Astro or Webflow, crawlable links and clean canonicals are part of the foundation from day one. See our webdesign approach, or get in touch if you want a second pair of eyes on your links.

Frequently asked questions

What is the use of href in SEO?

The href attribute holds the destination URL of a link, and it is what makes the link crawlable. Google generally only follows links that are <a> elements with an href, and it uses them to discover new pages and to understand what those pages are about through the anchor text. Without an href, a link may work for visitors but carries no value for search.

What happens if an anchor tag has no href?

An <a> element without an href is not a link Google can reliably follow. It may still work in the browser if JavaScript handles the click, but crawlers do not click, so the destination stays hidden from them. Google lists this pattern as not recommended. Put a real URL in the href and keep any JavaScript as an extra layer on top.

How does good anchor text help SEO?

Good anchor text tells people and Google what the linked page is about before anyone clicks. Descriptive, concise anchors help Google understand the destination and help readers decide whether to follow the link. Generic phrases like “click here” waste that context, and stuffing keywords into anchors violates Google’s spam policies. Write each anchor as a short, natural description of the page.

No. Opening a link in a new tab with target="_blank" is a user experience choice, and Google’s link guidance does not treat it as a ranking factor. Modern browsers apply noopener behaviour to these links automatically, and adding rel="noopener" yourself is a harmless safeguard. Tell readers the link opens a new tab, and keep new tabs for documents and external references.

Yes. Google still describes links as a signal for judging the relevance of pages and for finding new pages to crawl. What you want are links from relevant, trustworthy sites in a natural context. Buying or exchanging links to manipulate rankings counts as a link scheme under Google’s spam policies, so paid links need rel="sponsored" or nofollow.

Is a href the same as Ahrefs?

No. <a href> is the HTML code that creates a link on a web page. Ahrefs is a commercial SEO platform for backlink analysis, keyword research and site audits, and its name echoes that code. Many people search for one and mean the other. If you are comparing SEO tools rather than writing HTML, read our guide to Ahrefs.

Keep reading
All insights ↗