A dofollow link is a hyperlink that links to another page or website and is used by search engines to help rank websites. They help search engines to understand how popular a page is, which in turn influences its ranking in search results on Google and other search engines. Every dofollow link to an external site can be considered a 'vote' or recommendation for that site. There are many additional factors, but ranking highly in search results is usually partially a consequence of a page being linked to from many different websites.
The structure of HTML hyperlinks is very simple. By default, only one attribute is required, the 'href' attribute, which describes where to send people who click on the link. An example dofollow link to Google would be as follows:
An HTML link is considered a 'dofollow' link by default, so nothing extra is required. Unless there is some other mechanism used to block search engine crawl bots, like robots.txt, search engines will follow links that they find on web pages. A nofollow link allows webmasters to prevent search engines like Google from taking it into consideration when crawling a page. An example nofollow link to Google would be as follows:
<a href="https://www.google.com" rel="nofollow">Google</a>
The introduction of nofollow
Treating links as 'votes' for a page may not always be desirable behavior for webmasters. Since an external link is considered a recommendation for that site, webmasters may not wish to endorse a website while linking to it. Or, sometimes links may be there for private purposes, and the pages they link to are not intended for public consumption. In these cases, links can be marked as 'nofollow'. Google has recommended marking certain links as nofollow since 2005.
Adding the 'nofollow' rel attribute to a link may stop Google from following that link when crawling a site and it will not take that link as a 'vote' for the page it links to. This can be useful for a variety of reasons, as explained below.
Note: Since March 1, 2020, Google treats nofollow only as a hint and no longer as a directive. This means using nofollow is no longer a guarantee that Google will not follow a certain link.
Appropriate use of follow and nofollow
There are certain specific situations where you should follow best practices and mark links as nofollow. It is recommended by Google that certain types of links are marked as either nofollow or a more specific tag as mentioned below.
Links that have been paid for, such as online advertisements, should be marked as "sponsored". This is a relatively new variation of nofollow added by Google to further clarify the type of content linked. This is to prevent people from simply buying backlinks and gaming the system.
Comments and user-generated content
If your site has a comments section or some way for users to submit user-generated content which might include links, you should mark all links as "ugc". Spam, both automated and manually submitted, is an inevitable part of user-submitted content, so ugc helps to avoid problems without requiring excessive moderation.
If your site uses embedded content from third-party sources in some way, it is best to mark those links as nofollow. Generally speaking, if you can not control the source of some content, any links should be marked as nofollow to avoid potential issues with third-party content that is outside of your control.
There are plenty of other reasons you may wish to use nofollow links. There are no limits to which links you may mark as nofollow. Since links are considered dofollow by default and impact SEO, you may wish to link to a competitor without impacting their rankings, for example.
Importance for SEO
Search engines like Google treat dofollow links as 'votes' for a page. This is why having many high-quality dofollow backlinks is important for SEO and search ranking.
However, this does not mean website owners should only focus on building dofollow links for their website. Nofollow links are also an important part of a natural backlink profile and thus should not be neglected.