The principle: give Claude the real list of the site’s URLs, ask which pages should point to a target page (with the anchor and where to place the link), then write, check and measure the links. Six steps, including two scripts of a few lines.
1. Get the list of URLs
Claude doesn’t know your site. You have to give it the exact list of pages, and rebuild it before each internal linking job: a three-week-old export once made me write a link to an old, redirected address.
The sitemap is the simplest source: an index pointing to sub-sitemaps (posts, pages, categories). This script reads them all and writes a CSV, in about ten requests:
import csv, urllib.request, xml.etree.ElementTree as ET
NS = {"s": "http://www.sitemaps.org/schemas/sitemap/0.9"}
def read(url):
req = urllib.request.Request(url, headers={"User-Agent": "linking/1.0"})
return ET.fromstring(urllib.request.urlopen(req, timeout=30).read())
rows = []
for sm in read("https://mysite.com/sitemap_index.xml").findall("s:sitemap/s:loc", NS):
for u in read(sm.text).findall("s:url", NS):
lastmod = u.find("s:lastmod", NS)
rows.append((u.find("s:loc", NS).text, lastmod.text if lastmod is not None else ""))
with open("sitemap_urls.csv", "w", newline="", encoding="utf-8") as f:
csv.writer(f).writerows([("url", "lastmod")] + rows)
print(len(rows), "URLs")
No need to crawl the site page by page: it’s pointless, and a firewall can block you, as I found out.
2. Classify the pages
Add a “type” column to the CSV, by hand or by asking Claude to fill it from the URL: offer page, pillar page, article, case study, page to exclude (legal notices, careers, noindex pages). This column sets your priorities: links should point first to your offer pages and pillar pages, then to related articles.
3. Ask Claude a precise question
Attach the CSV and ask page by page, using this template:
Here is the list of my site's URLs (sitemap_urls.csv).
Target page: <URL>, topic: <topic in one sentence>.
Find the pages that should link to this target. For each one:
- the URL (only those in the file, invent none);
- a natural anchor of 2 to 5 words, different from page to page;
- the existing sentence where the link should go (quote it);
- why this link serves the reader.
Maximum 10 pages. Priority to offer pages and pillar pages.
Exclude pages that already link to the target.
Claude has to read the pages’ text to quote a real sentence. Paste it the HTML, or give it read access to the site, as in this note. Also ask the reverse question: which pages should the target point to?
4. Check before writing
Never trust a list of links without testing it. For each target URL: status 200, no redirect.
import urllib.request, urllib.error
def check(url):
req = urllib.request.Request(url, method="HEAD", headers={"User-Agent": "linking/1.0"})
try:
r = urllib.request.urlopen(req, timeout=20)
return r.status, r.geturl() != url # (status, redirected?)
except urllib.error.HTTPError as e:
return e.code, False
Also check by hand: anchors are varied (not ten times “email deliverability”), the link sits in a sentence that makes sense, and the source page doesn’t already link to the target.
5. Write the links
One or two links per page, in the body text, never stacked in the same paragraph. You can write them by hand in the editor, or have Claude write them with access limited to a list of pages, a backup before each change and a preview before writing, as in this note. Ask it to show the sentence before and after.
6. Measure
In Search Console, filter on the target page and follow impressions and position, day by day. Compare two to four weeks before and after. Example: a 5,000-word guide whose impressions had dropped to almost zero went back to 10 to 39 a day after 10 links, from 2 pillar pages and 8 articles. Other factors may have played a part, such as seasonality, so look at several pages before concluding.
Mistakes to avoid
- Linking from an old list: rebuild the CSV before each job.
- Linking to a redirected or noindex page: the test in step 4 catches them.
- Using the same anchor everywhere: ask for varied anchors.
- Trying to link everything: 5 to 10 well-placed links beat 50.
- Counting on links to fix cannibalization: if several of your pages target the same query, links change nothing. A pillar page linked from 20 of 21 articles was shown only 35 times in three months, because Google alternated between about ten pages with near-identical titles. Fix the titles first.
Key takeaway
An up-to-date sitemap, classification by priority, a precise question for Claude, URL testing, writing with safeguards, page-by-page measurement. Claude finds the links and drafts the anchors; you stay in control of what gets written.