Sub topic 5
Anchor text and what it tells a search engine
This chapter assumes you can read basic HTML and know that a crawler records each link's target URL, rel values, and visible text. The chapter on link anatomy covered those fields. Here the focus is on the visible text, called anchor text.
What anchor text is
Anchor text is the clickable text of a link, the content between the opening and closing <a> tags. A search engine reads it as a short description of the page the link points to.
<a href="https://example.com/guide">beginner SEO guide</a>Here the anchor text is "beginner SEO guide". If many independent pages link to the same URL with similar words, the engine learns what those authors think the target is about. This is why anchor text is one of the signals attached to a backlink, along with the source page and the rel values.
Where the text comes from
The visible words are not always plain text. Crawlers also handle these cases:
- Image links. When a link wraps an
<img>, the image'salttext is used as the anchor text. - Empty or icon-only links. A link with no text and no alt gives the engine nothing to learn from.
- Nested markup. Text inside
<span>or<strong>within the link still counts as anchor text.
<a href="https://example.com/guide"><img src="cover.png" alt="beginner SEO guide cover"></a>Types of anchor text
Anchors fall into a few common types. A natural backlink profile contains a mix of them.
| Type | Example | What it signals |
|---|---|---|
| Branded | "Example Co" | The target is associated with a name |
| Naked URL | "https://example.com/guide" | A bare reference with no topical wording |
| Exact match | "backlink checker" | The target is about this exact phrase |
| Partial match | "a free tool to check backlinks" | The topic, in natural wording |
| Generic | "click here", "read more" | Almost nothing about the target |
Extracting anchor text
The collector from the link anatomy chapter already records anchor text. This version counts how often each anchor appears for one target, which is the basic step of an anchor audit.
from collections import Counter
from html.parser import HTMLParser
class AnchorCounter(HTMLParser):
"""Count anchor texts for links that point to one target URL."""
def __init__(self, target):
super().__init__()
self.target = target
self.counts = Counter()
self._collecting = False
self._text = ""
def handle_starttag(self, tag, attrs):
if tag == "a" and dict(attrs).get("href") == self.target:
self._collecting = True
self._text = ""
def handle_data(self, data):
if self._collecting:
self._text += data
def handle_endtag(self, tag):
if tag == "a" and self._collecting:
self.counts[self._text.strip().lower()] += 1
self._collecting = False
pages = [
'<a href="https://example.com/guide">beginner SEO guide</a>',
'<a href="https://example.com/guide">click here</a>',
'<a href="https://example.com/guide">Beginner SEO Guide</a>',
'<a href="https://example.com/guide">Example Co</a>',
]
counter = AnchorCounter("https://example.com/guide")
for page in pages:
counter.feed(page)
for text, count in counter.counts.most_common():
print(count, text)The output shows "beginner SEO guide" twice, then "click here" and "example co" once each.
How the signal is used
Anchor text helps an engine decide what a target page is about, especially when the target has little text of its own. It also lets the engine tell apart pages whose content is similar. The signal is weak by itself. It is read together with the content of the target page and the text surrounding the link, so a link in a relevant paragraph says more than the same words in a footer.
Common mistakes
- Over-optimized anchors. If nearly every link to a page uses the same commercial phrase, the pattern looks arranged. Search engine spam policies treat keyword-stuffed anchors in link schemes as manipulation, covered in a later chapter.
- Generic anchors on your own links. Writing "click here" wastes a chance to describe the target. This applies to internal links as well.
- Assuming you control external anchors. You choose the anchors on your own site. Other sites choose theirs, and you should not ask for exact keyword text as a condition.
Exercise
A site has 40 backlinks to one page. 36 use the exact phrase "cheap running shoes", and 4 use the brand name. Why is this a concern, and what would a more natural profile look like?
Show answer
Nearly identical commercial anchors from many sources look like an arranged pattern, which spam policies on link schemes target. A natural profile mixes branded, naked URL, partial match, and generic anchors, because independent authors write different wording.