Automate SEO Redirect Testing with Python

As SEO’s, we all know redirect testing can be a time consuming task. Time spent formatting data and working across multiple files should be spent on analyzing the migration progress.

Through leveraging Python, redirect mappings can be tested efficiently while providing a clear view of the site migration progress  .

(Bring me to the script link)

Prerequisites.

To get started in streamlined redirect testing, you need the following:

  • A .csv file containing legacy URLs for testing
  • 301 redirects in place (can be at staging or production environment)
  • Unrestricted access to the new testing site (staging or prod).

If you have all of the above, then let’s get started!

What is a redirect map?

A redirect map is an essential part of a site migration strategy. Mapping out redirects from an old legacy site to the new will ensure that visitors are directed to the correct experience while maintaining SEO performance.

Not only are redirects valuable for maintaining a valuable user experience, they are also useful for providing search engine crawlers with new locations for relocated or retired webpages.

What does a redirect map look like?

Long story short, a redirect map is typically organized in a tabular form (excel file, csv, dataframe, etc), and consists of the following:

  • Source URL: the legacy or migrating site URL.
  • Source URL Status Code: the HTTP status code of the source URL.
  • Target URL: the new URL location, associated with the source URL.
  • Target URL Status Code: the HTTP status code of the target URL.

Note: A redirect map (in this context) is used for testing and organizational purposes. Structuring SEO redirects to be imported into a CMS (such as Magento 2, or Salesforce Commerce Cloud), will be dependent on the structure and syntax of that CMS.

Now, how all the URLs are gathered for a redirect map is a bit involved and out of scope for this article.

How do you test a redirect map?

One of the largest efforts in the redirect mapping process is the testing. If you don’t have a solid grasp on accurate testing, then a site migration can go very wrong and can be time consuming to resolve.

If you are new to site migrations, or dealing with a large site migration, it may be difficult to consolidate and streamline your testing efforts.

I always perform redirect testing on a staging or non-production environment to assure everything is working in a non-destructive environment.

Redirect map testing is:

  • Ensuring all the source (legacy) URLs have a 301 status.
    • If the legacy URL remains unchanged on the new site, then those URLs will be a 200 HTTP status code.
  • Verifying all the target (new) URLs have a 200 status code.

Sounds simple enough right? Well, in a perfect world yes, but we know that weird things can happen during the redirect mapping process.

How is this script different than using a redirect chains tool?

With this Python script, you won’t have to touch any of the URL data prior to running to script. You can export from GSC, SEMrush, a site crawl, or a combination of all 3, and load that file right into the script.

This is beneficial, because if you’re testing on a staging environment, then you will typically have to perform some level of data manipulation to swap the legacy URL with the staging URL. A step is removed from having to manipulate any data before testing, the less excel/data manipulation we have to perform, the better!

Automate redirects with Python today.

Follow the Google Colab link below and perform the following:

  • Save a copy of the notebook.
  • Comply with the Requirements & Considerations mentioned in the Colab file.
  • Run All
  • Follow the prompts as they appear
    • Upload csv file
    • Enter the full legacy domain
    • Enter the full domain (new or staging) that you’re testing against
  • Analyze the output file and make the necessary adjustments to your redirect map!


Posted

in

,

by

Comments

Leave a Reply

Discover more from Tyler Gargula

Subscribe now to keep reading and get access to the full archive.

Continue reading