How to add rel=nofollow to all external links on your Shopify store?
Before digging into the steps on how to set rel=follow to all external links (to all links in blog posts and on any other pages on your Shopify store), let’s explain what rel=nofollow means and in which cases you should use it.
rel=nofollow in short
We use the rel
attribute (a link’s attribute) to provide context about the relation of the linking page (i.e. your blog post) with the link target (i.e. an external page). The rel
link’s attribute can contain various values, e.g. nofollow, noreferrer, noopener, ugc, sponsored, and else. Even combination of multiple values is possible.
The nofollow value is used to inform the search engines (e.g. Google) that they shouldn’t follow these links and therefore shouldn’t pass any link authority to the linked URL.
However, from March 1, 2020, Google doesn’t strictly follow the directive but instead, uses the nofollow link’s attribute as a mere hint. In other words, Google can ignore the nofollow value of the link’s attribute and use the links for ranking purposes as well.
When should you use rel=nofollow?
The nofollow value of the link’s attribute should be used only when you want to link to an external page but don’t want to imply any type of endorsement to the referenced page, e.g. when the link hasn’t occurred naturally.
To give you specific examples, the nofollow value might come in handy when the destination URL is e.g. press release, widgets, forum comments, or similar.
Add rel=nofollow to all external links using JavaScript
If you’re sure that all external links on your Shopify store should have this link’s attribute value assigned (read the paragraph above), then use the following piece of JavaScript code, which will automatically assign the rel
attribute and its value to all external links.
- Go to Shopify admin -> Themes -> Choose the theme -> Click the three dots.
- Click Edit code.
- Find the general JavaScript file, e.g. global.js (Dawn Theme).
- Place the following piece of code at the end of the file.
- Please notice that this example code uses more than one
rel
attribute values. You can add more values, if needed, or just keep those, which are relevant for your store. - Save the file and open your store.
- Find an external link on your store and open the web developers tools.
- Inspect the external link and you should see the
rel
attribute with its values added to the link.
And that’s it! If you get stuck in any of the steps mentioned above, let’s know! We’ll be happy to help you out.