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.

SEOAgent
October 25, 2026
7 min read
The PageRank Algorithm Explained: Formula, Code and What It Means for SEO
On this page

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 page q that links to p.
  • L(q) is the number of outbound links on q. A page splits its score evenly across its links, so a page with 50 links passes each one less than a page with 2.
  • d is the damping factor. The original paper suggests 0.85.
  • (1 - d) / N is 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.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

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.

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

Tags:SEOSEO for Developers

Put SEO on autopilot in your own editor

SEOAgent runs as a free skill inside Claude Code, Cursor, and Codex — on the model you already pay for. Audit, plan, and write SEO content right in your repo, with every change reviewed before it ships. No second AI subscription.

What do you use to work on your site?

Pick one above and we take you to the right setup.

Get SEOAgent free