Coding Script or NotebookGoogle ColabAcademy
Topic Clustering Notebook for Internal Linking: BERTopic and K-means
Topic clusters give your linking rules fences: pages in the same cluster are natural link partners, and links across clusters can be chosen on purpose. This Google Colab notebook builds those clusters from your own content.
What it helps you do
- Run BERTopic and K-means on the same pages, side by side, and compare the results
- Label each topic automatically, and give every URL a cluster ID and a topic label
- Reuse the embeddings you made in the previous lab, so you don’t need an API key (there is a fallback if you skipped that step)
- Export a cluster map for the scoring and automation steps that follow
A written walkthrough of the lab comes with it.
Where it is used
Lesson 3.4, after the clustering theory in Lesson 3.3. Sam Torres notes it is a method she uses on all kinds of SEO projects, well beyond linking.
It comes with the AI-powered Internal Linking Audit and Automation course, led by Sam Torres. If you want to build the whole pipeline from audit to measured links with her, that is the place to start.
What’s included
- BERTopic and K-means side by side on the same pages
- Automatic topic labels
- A cluster ID and topic label for every URL
- Reuses the embeddings from the previous lab, so no API key is needed
- Exports a cluster map for the scoring and automation steps
Where this resource is used on MLforSEO
Walkthroughs on the blog
Concepts behind it
More internal linking resources
- Coding Script or NotebookLink Blocks for WordPress: Related Posts, Topic Cards, Siblings and Mentions
- Coding Script or NotebookLink Menu to Linking Rules: Python Script for Auto-linking Plugins
- ChecklistBefore You Build: A Checklist for Internal Linking Tools
- Coding Script or NotebookInternal Linking QA and Holdout Group Notebook
- Visualization TemplateInternal Linking Impact Dashboard (Data Studio Template) with Setup Guide
- Coding Script or NotebookInternal Link Menu Notebook: Priority Score and Versioned Recommendations
See all 26 internal linking resources →See all 29 content analysis resources →See all 73 coding script or notebook resources →
