Link Audit
A link audit counts and classifies every link on a page (internal, external, nofollow, sponsored, broken) so you can spot crawl and authority problems at a glance.
Why it matters
A page's link count and mix reveal two critical things: how much crawl budget you're spending, and whether paid or UGC links carry the correct rel value under Google's policy. A link audit catches silent problems early; a template that accidentally marked internal nav links as rel="sponsored", or a footer that became a link farm, can spread across hundreds of pages before anyone notices.
A page with 200 links isn't the same as one with 20. The crawl and authority implications are utterly different. Without breaking links by category (internal, external, nofollow, sponsored, UGC), you're flying blind.
How it works
A link audit enumerates every <a> tag with an href attribute on a page, then buckets each one by its destination scheme and rel attributes. The process works in order:
- Parse the page HTML for all
<a>elements with non-empty href. - For each link, extract the href, rel attribute (if present), and protocol.
- Classify by destination: does the href resolve to the same domain (internal), a different domain (external), or a non-http scheme (mailto, tel, javascript)?
- For external links, extract the rel attribute values: nofollow, sponsored, ugc, or none.
- Count and report each category separately.
Duplicate links pointing to the same destination are counted only once per page: you're tracking unique destinations, not every click target. This prevents nav items that appear on every page from inflating the count.
The total link count is the sum of all categories. What matters is the breakdown: a page with 100 internal links and 2 external ones has a very different profile than one with 40 internal and 60 external.
What does not matter
Link count alone is not a ranking factor. Google doesn't penalise pages for having many links or reward them for having few. What matters is the quality of the destinations and the accuracy of the rel attributes, not the sheer volume.
Also, anchor links (fragment hrefs starting with #) don't factor into SEO link metrics. They're navigation within the page, not cross-page signals. An audit should separate them out so they don't pollute the internal-link count.
Code example
Here's a minimal audit function that classifies links by category:
// Classify all links on the page
const auditLinks = () => {
const links = {
internal: [],
external: [],
nofollow: [],
sponsored: [],
ugc: [],
anchor: [],
mailto: [],
tel: [],
other: []
};
document.querySelectorAll('a[href]').forEach(a => {
const href = a.getAttribute('href');
const rel = a.getAttribute('rel') || '';
if (href.startsWith('#')) {
links.anchor.push(href);
} else if (href.startsWith('mailto:')) {
links.mailto.push(href);
} else if (href.startsWith('tel:')) {
links.tel.push(href);
} else if (new URL(href, window.location.origin).hostname === window.location.hostname) {
links.internal.push(href);
} else if (href.startsWith('http')) {
links.external.push(href);
if (rel.includes('nofollow')) links.nofollow.push(href);
if (rel.includes('sponsored')) links.sponsored.push(href);
if (rel.includes('ugc')) links.ugc.push(href);
} else {
links.other.push(href);
}
});
return links;
};
// Run the audit
const audit = auditLinks();
console.log(`Total links: ${Object.values(audit).flat().length}`);
console.log(`Internal: ${audit.internal.length}, External: ${audit.external.length}`);
This script walks every link once and puts it in a bucket. You can then inspect each category to spot orphan pages (zero internal links in), link farms (excessive external links to low-quality domains), and missing rel attributes on paid or UGC links.
Checking your links
The best way to spot link problems before they affect your rankings is to run an audit on each important page. Start with your homepage and conversion pages, then any page that's been revamped. Broken links are obvious; the real wins come from spotting pages that are either link-starved (zero internal links pointing in) or accidentally marked as UGC or sponsored when they shouldn't be. Scalpel's Links tab filters by each category so you can investigate without manual scrolling.