2024-01-18

Exclude Page Sections via XPath in InternalLinking

Nick Swan

One recurring bit of feedback we received while building InternalLinking was the ability to exclude common elements of a page from the reports, such as headers, footers, and sidebars. The tool did ignore the HTML 5 header and footer elements, but not all sites use these. So we needed a way to ignore any <div> from a site.

The good news is InternalLinking can now do this via XPath selectors.

You can now exclude sections of pages when you want InternalLinking to look for new internal link suggestions.

You must copy the XPath selector for the section you wish to exclude and paste this into InternalLinking during the report creation process.

For example, a sidebar on the SEOTesting site appears on all pages, sometimes including phrases we commonly look for via our InternalLinking reports. All I need to do to exclude this is copy the XPath selector for the sidebar from Google Chrome developer tools.

Right-click context menu on a webpage with 'Inspect' highlighted, showing the option to view a page's elements for a testimonials section.

In the Google Chrome browser, right-click the element on the page you wish to be ignored in InternalLinking, and select Inspect from the context menu.

Context menu in a web browser's developer tools open on HTML elements with the 'Copy XPath' option highlighted.

Now, right-click on the HTML element in Chrome Developer tools and go to Copy -> XPath. You can now paste it into the XPath section under the "advanced options" tab during the report creation phase:

A web report creation screen with advanced options section open, highlighting the field to add an XPath pattern for excluding elements from report results.

This will run the InternalLinking report, ignoring the XPath-selected HTML element. The report heading section displays any XPaths used to remove sections from the crawled pages.

Report view screen showing excluded elements section with a specified XPath, targeting elements to omit from the report for seotesting.com/blog.

Common sections to exclude using XPath

Headers

Headers naturally appear on every page of your site and, most often, contain a lot of keywords that are valuable to your business. Coming from an InternalLinking point of view, the trouble with this is that most of these opportunities will be linked anyway.

Header of an article on seotesting.com about Brand vs Non-Brand SEO Report with a colorful graphic.

This is especially true for ecommerce businesses and information-based sites with header links to their website's important pages. Yes, these are important, but these are already linked so you do not need these showing up on your InternalLinking reports in most cases.

Footers

In the same way that headers provide little to no value in your InternalLinking reviews, footers have the same issues, too. In most cases, you do not need the text in your footer showing up on your reports, as these keyword opportunities will already be linked.

Footer of seotesting.com with menu links, company information, and privacy policy against a purple gradient background.

Unless, of course, you are working on a brand new website.

Other Common Page Sections

There are, in reality, limitless use cases for this new InternalLinking feature! Any section of your website that shows up on all/most pages does not necessarily need to be included in your InternalLinking reports.

Our primary example is the "testimonial" section on our website, which also shows up on every single blog post:

Webpage content on internal linking importance for SEO with a sidebar featuring testimonials and a try for free button.

As you can see in the testimonial we have from Aleyda Solis, there are lots of SEO-related terms:

  • Low hanging fruit
  • SEO
  • SEO tests
  • Reports

These terms would be regularly written in our blog posts, creating good internal link opportunities. The only problem is that we do not need to link them from this testimonial section internally.

The new feature within InternalLinking allows us to remove this section from InternalLinking reports entirely. We must copy the XPath and paste it into InternalLinking when we create our reports.