Google Colab for SEO: How to get started
Google Colab has been around since 2017 but has gained more popularity recently from SEO professionals sharing code samples.
SEOs **** Colab because, unlike GitHub, you can actually run the code directly on the platform.
What is Google Colab?
Google Colab is a tool that allows users to quickly run Python directly on the platform with little to no setup. Google Colab is a hosted Jupyter Notebook that uses Google’s hosting services in the cloud.
In case you’re new to Python, a Jupyter Notebook is a free online tool you can use online to write code, solve math problems, make graphs and show your work. It’s like a digital notebook that helps you keep all of your project parts in one place and share them easily with others.
The best part about Google Colab? It’s free.
If you require more computing power, there is a tier pricing system. As of writing this, I pay $9.99 per month for the first paid tier. The next tier is $49.99 per month and then there’s a custom enterprise version.
Benefits of Google Colab
I’ve personally reaped the benefits of Google Colab for several years and am pleased to share what I’ve found to be its biggest benefits for SEOs.
Fast to start
If you’ve ever installed Python on your local machine, then you know firsthand how annoying it is to get Python set up. Also, if you’re trying a new bit of code, then you’re likely having to install new libraries to get your code to run.
The best part about Google Colab is that most common Python libraries are already installed on Google Colab. If something is missing, you can simply run:
!pip install new-library
The one nuance here is that you need the exclamation point before pip to install a new library.
Doesn’t use your computer’s bandwidth
I often use Python to compute large datasets, which can take quite a bit of time. I’ve run some bits of code that take hours to compute due to the size of the data.
In SEO, we often run crawls and other analyses in the background while we work. Have you ever run a Screaming Frog crawl that completely slows down your computer, making it nearly impossible to do other SEO tasks?
With Google Colab, you can seamlessly run compute-intensive code and work on other SEO tasks while the code runs.
Shareable
Google Colab is meant to be easily shared with collaborators or the world. As someone who believes in the power of open source, I believe that Google Colab is great for me to share code with the SEO community.
AI integration
Google has integrated Gemini directly into Google Colab. So, if you’re struggling to build a new feature in your code, you can leverage AI to help generate new code features.
I would urge caution when doing this, as you may find yourself debugging more than helping yourself.
Dig deeper: Can AI perform technical SEO analysis effectively?
Get the daily newsletter search marketers rely on.
How to use Google Colab
Let’s dive right into how to use Google Colab. I’ll run you through the eight most important features to get you right to coding for SEO.
How to run code
Probably the most simple step here is to know how to actually run the code.
Once you’re ready to run your code, click the play button.
How to open the folder pane
To run code that relies on any source data or exports results into a file, you’ll need to be able to open the folder. Luckily, just like running code, this is just one button, specifically the one that looks like a folder.
How to connect to Google Drive
One of the great things about Google Colab is that it’s part of the Google suite of tools, allowing you to connect directly to files in Google Drive and even save your results to Google Drive.
To connect to Google Drive, you first need to mount It by clicking the button shown in the screenshot below.
Once Colab finishes mounting Google Drive, your Google Drive folder will appear in the files pane.
From here, you’re able to reference any of those files by right-clicking on the file, selecting a copy path and pasting it wherever you reference a file in your code.
How to upload files manually
Before uploading files, note that anything you upload will not be saved and will only be used as temporary files. Those files will disappear once you refresh the page or close it.
If you want the files to stay available, you’ll need to use Google Drive and connect to them that way (see previous steps).
If you’re OK using files temporarily, then you have two options. You can drag and drop your files from your computer to the files pane or click the upload button.
How to create new files directly in Google Colab
Sometimes, I find it easier to create new files directly in Google Colab.
For example, if I have a bunch of keywords I want to analyze, it’s easier for me to copy them and paste them into a file in Colab rather than create a new file locally on my computer and upload it.
To do this, just right-click on a blank space in the files pane and click New File. From there, you can name it whatever you want, and paste your data and then save it with your hotkeys (Command + S or Control + S).
How to download results
Once you’ve run the code, you may have an exported file created in the process.
You can preview the file by double-clicking on it, but if you want to download it, all you need to do is right-click on it and select Download.
How to connect to a runtime
If you’re running code that may take a more heavy compute load, you may want to experiment with a faster runtime.
To do this, select Runtime in the top menu and then in the dropdown, select Change runtime type.
From there, you’ll see some options that you can change.
Please note that if you’re going to change the runtime, any files in the file pane will disappear.
How to use the AI integration
One of the latest features in Google Colab is the integration of Gemini. Google has made it easy to take advantage of this new feature by adding a Gemini button in the top right of the screen.
By clicking that, a sidebar will appear for you to ask it prompts.
Free code to get you started
Now that you’ve taken the crash course to getting started with Google Colab, it’s time to try some code!
In one of my previous articles, I’ve provided five Python scripts for SEO that you can try right now in Google Colab.
In that article, you will be able to see the context of the scripts, how to set them up and I provide the actual code for you to try.
It’s never been easier to get started in Python for SEO. Happy coding!
Contributing authors are invited to create content for Search Engine Land and are chosen for their expertise and contribution to the search community. Our contributors work under the oversight of the editorial staff and contributions are checked for quality and relevance to our readers. The opinions they express are their own.
Source link : Searchengineland.com