Internal link text is one of the clearest signals you control about what each page on your site is for. Search engines and AI answer engines both read it. Most sites never audit it.
Here's a read-only snippet you can paste into the browser console to check any page in a few seconds.
What "good" looks like
Google's guidance says link text should be "descriptive, reasonably concise, and relevant to the page that it's on and to the page it links to." It lists "Click here" as an example to avoid.
Two rules on top of that make a link plan easy to maintain:
- A page never links twice to the same destination.
- The same words never lead to two different pages.
The snippet
Open a page, press F12, go to Console, paste:
(() => {
const generic = /^(click here|here|read more|learn more|more|this|this page|link|see more|continue)$/i;
const host = location.hostname.replace(/^www\./, '');
const main = document.querySelector('main, article, [role=main]') || document.body;
const rows = [];
for (const a of main.querySelectorAll('a[href]')) {
let url;
try { url = new URL(a.getAttribute('href'), location.href); } catch { continue; }
if (url.hostname.replace(/^www\./, '') !== host) continue;
if (url.hash && url.pathname === location.pathname) continue;
const text = (a.innerText || a.getAttribute('aria-label') || a.querySelector('img')?.alt || '').trim().replace(/\s+/g, ' ');
rows.push({ text, to: url.pathname + url.search });
}
const byDest = {}, byText = {};
for (const r of rows) {
(byDest[r.to] ||= []).push(r.text);
(byText[r.text.toLowerCase()] ||= new Set()).add(r.to);
}
const issues = [];
for (const r of rows) {
if (!r.text) issues.push(['empty text', r.to, '']);
else if (generic.test(r.text)) issues.push(['generic text', r.to, r.text]);
}
for (const [to, texts] of Object.entries(byDest))
if (texts.length > 1) issues.push(['same page linked ' + texts.length + 'x', to, texts.join(' | ')]);
for (const [text, dests] of Object.entries(byText))
if (text && dests.size > 1) issues.push(['same words, ' + dests.size + ' pages', [...dests].join(' , '), text]);
console.log(rows.length + ' internal links in the main content');
console.table(rows);
console.log(issues.length + ' things to check');
console.table(issues.map(([problem, to, text]) => ({ problem, to, text })));
return { links: rows.length, issues: issues.length };
})();
It prints two tables:
- every internal link inside
main/article(falls back tobody), with its text and path; - the things to check: empty text, generic text ("click here", "read more"...), the same page linked more than once, and the same words pointing to different pages.
How it works
- It resolves every
hrefagainst the current URL and keeps only same-host links (with or withoutwww). - Jump links to the same page (
#section) are skipped. - For the link text it uses
innerText, thenaria-label, then thealtof an image inside the link. - It groups links by destination and by lower-cased text to find the two rule violations.
What it doesn't do
It checks one page at a time and doesn't follow links, so it won't tell you which ones redirect or 404. For that you still need a crawl. It also ignores the menu and footer when the page has a main or article element, on purpose: the links inside the text are the ones that explain why another page is useful.
Next step
Write a plan for your ten most important pages (from which page, to which page, with what words), add the links, run the snippet on each page, then crawl.
The full method, with the video and a worksheet, is lesson 6.2 of our free AEO and GEO course: https://citeproof.co/courses/aeo-geo/internal-links-wordpress-shopify-wix?utm_source=devto&utm_medium=parasite&utm_campaign=internal-links-audit
I'm the founder of CiteProof, which builds this link plan automatically for WordPress and Shopify. Originally published on Medium.
Top comments (0)