The PageRank Algorithm Explained: Formula, Code and What It Means for SEO
PageRank scores a page by the links pointing at it, weighted by the score of the pages that link. Here is the formula, a runnable example, and what developers can still use.

On this page
- The idea: a random surfer
- The PageRank formula
- What the damping factor does
- A worked example you can run
- The same calculation with networkx
- The matrix form and power iteration
- PageRank vs "keyword PageRank" and third-party scores
- Does Google still use PageRank?
- What developers can do with it
- How to increase PageRank
- PageRank tracking: what you can actually measure
- What PageRank does not tell you
- Auditing your own link graph
- References
PageRank is the link-analysis algorithm Larry Page and Sergey Brin described at Stanford in 1998 and used as the foundation of Google Search. It gives every page in a link graph a score, and the score of a page depends on how many pages link to it and how high those pages score themselves. A link from an important page counts for more than a link from an obscure one.
This page covers the formula, the damping factor, a small worked example you can run, and what PageRank does and does not tell you about SEO today. Google has said it still uses PageRank as one signal among many, so the idea is worth understanding even though you cannot see the number.
The idea: a random surfer
The original paper, The Anatomy of a Large-Scale Hypertextual Web Search Engine, explains PageRank with a "random surfer". Imagine someone who lands on a random page, clicks a random link on it, and repeats. Most of the time they follow a link. Occasionally they get bored and jump to a random page instead. A page's PageRank is the probability that this surfer is on that page at any given moment.
Two consequences follow:
- A page with many inbound links is visited more often.
- A link from a page that is itself visited often passes along more of that probability.
The PageRank formula
For a page p in a graph of N pages:
PR(p) = (1 - d) / N + d * sum( PR(q) / L(q) ) for every page q that links to p
PR(q)is the current score of a pageqthat links top.L(q)is the number of outbound links onq. A page splits its score evenly across its links, so a page with 50 links passes each one less than a page with 2.dis the damping factor. The original paper suggests 0.85.(1 - d) / Nis the share every page gets for free from the "jump to a random page" behavior.
The scores form a system of equations where each score depends on the others. In practice you solve it by iteration: start every page at 1 / N, apply the formula repeatedly, and stop when the scores stop changing.
What the damping factor does
With d = 0.85, the surfer follows a link 85% of the time and jumps to a random page 15% of the time. That random jump solves two real problems:
- Dead ends. Pages with no outbound links would otherwise trap the surfer. The jump lets probability flow back out.
- Loops. A small cluster of pages that only link to each other would soak up all the score. The jump keeps every page above a minimum,
(1 - d) / N.
A higher d makes the result depend more on the link structure and converge more slowly. A lower d flattens the scores toward equal.
A worked example you can run
Take four pages: A links to B and C, B links to C, C links to A, and D links to C. Nothing links to D.
links = {"A": ["B", "C"], "B": ["C"], "C": ["A"], "D": ["C"]}
N, d = len(links), 0.85
pr = {page: 1 / N for page in links}
for _ in range(50):
new = {page: (1 - d) / N for page in links}
for page, outlinks in links.items():
for target in outlinks:
new[target] += d * pr[page] / len(outlinks)
pr = new
print({page: round(score, 3) for page, score in pr.items()})
After 50 iterations the output is:
{'A': 0.373, 'B': 0.196, 'C': 0.394, 'D': 0.038}
Read it like this:
- C ranks highest because three pages link to it, including A, which is itself well linked.
- A ranks nearly as high despite having one inbound link, because that link comes from C, the top-scoring page, and C has only one outbound link, so it passes all of its score to A.
- D sits at 0.038, which is exactly
(1 - 0.85) / 4. With no inbound links it only gets the free share every page receives. - The scores sum to 1, because they are probabilities.
At web scale the same calculation runs over billions of pages, using sparse matrix methods rather than a Python loop, but the principle is the same.
The same calculation with networkx
You do not have to hand-roll the loop. networkx implements the same algorithm, with alpha as the damping factor:
import networkx as nx
G = nx.DiGraph([("A", "B"), ("A", "C"), ("B", "C"), ("C", "A"), ("D", "C")])
print(nx.pagerank(G, alpha=0.85))
The scores match the hand-written loop to within the convergence tolerance.
The matrix form and power iteration
Mathematically, the loop above is power iteration. Build a column-stochastic matrix M where M[i][j] = 1 / L(j) if page j links to page i, and the PageRank vector r satisfies:
r = d * M * r + ((1 - d) / N) * 1
Repeating that multiplication until r stops changing converges to the dominant eigenvector of the "Google matrix". Because the matrix is sparse, each iteration costs roughly the number of links, not N squared, which is why the method scales to web-sized graphs.
PageRank vs "keyword PageRank" and third-party scores
Searchers often type "keyword pagerank" or "seo tools page rank". Two clarifications:
- PageRank is query-independent. The base algorithm gives each page one score regardless of the search. Research on topic-sensitive PageRank (Haveliwala, 2002) biases the random jump toward pages on a topic, which is the academic version of "PageRank for a keyword". Google does not publish whether or how it uses such variants.
- Tool scores are not PageRank. Metrics such as Moz Page Authority, Ahrefs URL Rating and Semrush Authority Score are each vendor's own model of link strength, built from that vendor's crawl. They borrow the PageRank idea and are useful for comparing pages within one tool, but they are not Google's number and do not translate between tools.
Does Google still use PageRank?
Yes, in some form, but it is not the whole story and you cannot read it.
- Google stopped showing Toolbar PageRank in 2016, so the 0 to 10 score you may remember from the browser toolbar is gone. Third-party "PageRank checkers" now are estimates built from other data, not Google's number.
- Google's documentation describes links as a way to find pages and a signal about whether other sites consider content useful. See Google's link best practices.
- Ranking uses many other signals. PageRank is about link authority, not whether a page answers the query.
Treat PageRank as a model of how link equity flows, not a metric to chase.
What developers can do with it
You do not control Google's calculation, but you control your own link graph, and the model above gives some concrete guidance.
- Make internal links crawlable. Use real
<a href>links in rendered HTML. A page that is only reachable through JavaScript click handlers or a search box may never receive internal link equity. Our guide to what crawling is and how to check it shows how to test this. - Avoid orphan pages. A page with no inbound internal links is page D in the example: it gets almost nothing. List every URL in the sitemap, then check each has at least one internal link. Next.js sitemap covers generating the list.
- Link from strong pages to the pages that matter. Because a page splits its score across its links, a link from your most-linked page to a key landing page is worth more than a link from a rarely visited one. Pages linked from the home page or main navigation are usually the best-connected.
- Do not bury key links among hundreds of others. Link-heavy footers and mega-menus dilute what each link passes in the PageRank model. Prefer contextual links in body copy.
- Earn relevant external links. Inbound links from other sites bring score in from outside your graph. Understand the difference between external links and internal ones, and use Google Search Console to see who links to you.
- Keep link text descriptive. Anchor text is a separate relevance signal from PageRank, but it is cheap to get right.
For the wider checklist of technical basics, see SEO for developers and Next.js SEO.
How to increase PageRank
The formula shows exactly three levers, and each maps to something you can do:
| Lever in the formula | What it means for a page | What to do |
|---|---|---|
More pages q linking to p |
More inbound links | Earn relevant external links; add internal links from related pages |
Higher PR(q) of those linking pages |
Links from strong pages | Link to important pages from your best-linked pages (home page, hub pages) |
Lower L(q) on the linking pages |
Fewer competing links on the source page | Keep key links in body copy, not buried among hundreds of footer links |
Practical steps, in order of how much control you have:
- Fix orphan pages first. A page with zero inbound internal links is stuck at the minimum share.
- Add contextual internal links from topically related, well-linked pages to the page you want to lift, using descriptive anchor text.
- Shorten click depth. Pages reachable in one or two clicks from the home page tend to be the best connected.
- Redirect and consolidate. Point duplicate and retired URLs at the canonical page with a 301 so their inbound links are not wasted, and keep redirect chains short.
- Earn external links with something worth citing, such as original data, a tool, or a clear reference page. Buying links violates Google's spam policies and can get a site demoted.
Nothing here guarantees a ranking change. PageRank is one input, and the number you cannot see cannot be targeted directly.
PageRank tracking: what you can actually measure
Since Google no longer exposes the score, "page rank tracking" means tracking proxies:
- Your own internal PageRank. Crawl your site, build the link graph and compute scores with the networkx snippet above. Re-run it after each release to see which pages gained or lost internal equity. This is the only PageRank-style number you fully control.
- Referring domains and linked pages. The Links report in Google Search Console lists your top linked pages and linking sites. See how to read Search Console backlinks.
- Third-party authority scores. Track Page Authority, URL Rating or similar over time in the tool you use, and compare only within that tool.
- Rankings and clicks. The outcome that matters. Track impressions, clicks and average position per page in Search Console.
What PageRank does not tell you
- Quality of content. A well-linked page can still rank poorly for a query it does not answer.
- Relevance. Links from topically related pages are a different matter from raw link count.
- Traffic. PageRank is a model of authority, not visits.
- Anything about AI answers. Citations in AI answer engines draw on different signals, which we cover in AEO vs SEO.
Auditing your own link graph
You can compute a PageRank-style score for your own site: crawl it, build the links dictionary from each page's internal <a href> targets, and run the loop above. The pages that come out lowest are the ones your internal linking neglects.
SEOAgent can help with the audit side of this. The free Skill and local seoagent CLI run inside your own coding agent on your own model, check internal links and orphan pages in your repo, and write proposed changes as file edits you review before anything ships. It does not need a second subscription for the model, and it does not compute Google's PageRank, which nobody outside Google can do. It requires a coding agent, and the cloud data features are a paid tier. The SEO optimization workflow lists what it checks.
References
- Brin, S. and Page, L. The Anatomy of a Large-Scale Hypertextual Web Search Engine (Stanford, 1998)
- Page, L., Brin, S., Motwani, R. and Winograd, T. The PageRank Citation Ranking: Bringing Order to the Web (Stanford InfoLab, 1999)
- Google Search Central: Link best practices
- Search Engine Land: Google confirms Toolbar PageRank is dead
- Haveliwala, T. Topic-Sensitive PageRank (WWW 2002)
- networkx: pagerank
- Google Search Central: Spam policies, link spam
SEOAgent for GitHub
Your first SEO pull request in about 5 minutes.
Connect the repo your site lives in. SEOAgent finds what holds the site back in search and fixes it in pull requests. You review and merge every change.
- ✓14 days free
- ✓No card
- ✓$79/site/month after
- ✓What SEOAgent found, and the plan for your site
- ✓Meta descriptions for 14 pages
- ✓Sitemap and robots.txt
- ✓Organization schema
- 370+sites
- 1,100+articles written
- 3,500+SEO changes made