Skip to content

Bookmarklet: Highlight duplicate links on a page

By Updated at 3 min read
By - Updated on

Here is a bookmarklet that simplifies life when doing a quick SEO review of a page. It highlights duplicate links found on the page in bright yellow.

If your content editor (TinyMCE, CKEditor, Gutenberg or other) tends to create empty links, dashes will be inserted inside them to make them visible. If the link is not visible on the page (display: none or other), you’ll need to check the Console (F12, developer tools) in your browser.

javascript:(function() {
  var links = document.getElementsByTagName("a");
  var linkMap = {};
  for (var i = 0; i < links.length; i++) {
    var href = links[i].getAttribute("href");
    if (links[i].innerHTML.length < 1) {
      links[i].innerHTML = "---";
    }
    if (href && href.length > 0) {
      if (linkMap[href]) {
        linkMap[href].push(links[i]);
      } else {
        linkMap[href] = [links[i]];
      }
    }
  }
  var duplicates = [];
  for (var key in linkMap) {
    if (linkMap[key].length > 1) {
      duplicates.push(linkMap[key]);
    }
  }
  if (duplicates.length > 0) {
    console.log("Found " + duplicates.length
      + " sets of duplicate links:");
    for (var i = 0; i < duplicates.length; i++) {
      for (var j = 0; j < duplicates[i].length; j++) {
        console.log(duplicates[i][j]);
        duplicates[i][j].style.backgroundColor = "#ffff00";
      }
    }
  } else {
    console.log("No duplicate links found.");
  }
})();

Test this bookmarklet directly on this page — it will highlight at least one link to the homepage that repeats three times: header, breadcrumb, footer.

How do I use duplicate link detection?

In 2 ways:

  • During a crawl of an audited website
  • While editing a long page

Most of the time, I leave things as they are. In certain situations, I choose to obfuscate one of the duplicate links. When I get to work with a CMS that allows some SEO tricks, I add the rel attribute delete-if-duplicate. During page generation, this HTML attribute is removed, and if the link already exists in the content, it gets obfuscated.

Is PageRank sculpting a dinosaur SEO practice?

In my humble opinion, experience indicates that the technique is still valid in 2026.

Share, comment and feedback on X (Twitter) or directly by email.

Also read

Email • RSS • Twitter

Get notified of new posts