Skip to content
Coding Script or NotebookGoogle ColabFree

Entity Internal Link Map and Link Rules from Your Entity Audit

ForInternal linkingEntity SEO

By Lazarina Stoy· Updated 5 Dec 2026

Once you know which page owns each entity, internal links almost write themselves: every mention elsewhere on the site is a chance to link to the owner. These two free Python scripts turn your entity audit into that link plan, and into rules an auto-linking plugin can apply.

Who it’s for

SEOs who have run an entity audit and want entity linking across a site, on WordPress or any CMS where links can be added at build time.

How to use it

  1. Open the course scripts notebook in Colab (or download the folder from GitHub to run it on your computer).
  2. Add the keys the script needs as Colab secrets, with notebook access switched on. They never go into the code.
  3. Run the Setup cell. It downloads the scripts and installs what they need.
  4. Upload entity_mentions.csv and page_entity_profiles.csv from the Entity Extractor, your naming table, and Screaming Frog’s All Inlinks export.
  5. Run link_map.py. It maps each entity to its owner page, drops links that already exist and proposes a few links per source page.
  6. Check the owners the script guessed. Those rules stay switched off until you do.
  7. Preview the rules with apply_link_rules.py on saved pages: it reports what it would link, and writes linked copies only with --write.

What you get

  • link_plan.csv: source, target, entity, anchor and priority, in rounds of 20
  • link_rules.json: one rule per entity with its variants, in the format the MLforSEO Auto Links plugin imports
  • link_rules.csv: keyword, URL and cap, for other auto-linking plugins
  • A preview that never links inside headings, code, buttons or navigation, never self-links and respects each rule’s cap

Limits

  • It proposes links from the numbers; you decide which ones go live.
  • Rules fire on every mention, so check variants that could mean something else.
  • Free, no API calls.

Why owners first

Linking every mention to whatever page ranks is how sites end up with three pages competing for one entity. Deciding the owner first, in your naming table, means every link points the same way and reinforces one page.

Start with a small round of links, check those pages after they go live, then run the next round. Mistakes stay small that way.

The preview engine is also used in AI-powered Internal Linking Audit and Automation to test rules built from a link menu. The scripts are on GitHub; the The AI-powered Entity Audit course covers how to choose owner pages.

What’s included

  • Maps each entity to the page that owns it, minus links that already exist
  • A link plan in rounds of 20, prioritising orphan targets
  • Link rules as JSON (with variants) and as a flat CSV
  • A preview engine that applies the rules to HTML the way an auto-linking plugin would
  • Free: no API calls, guessed owners stay switched off