How to add ‘nofollow’ flag to all Tag archive hyperlinks?

I already had this challenge before and here is my personal solution for you:

1. For the tag cloud widget you can use this approach:

add_filter('wp_tag_cloud', 'add_nofollow_to_tag_cloud');
function add_nofollow_to_tag_cloud($content) {
    // Add 'nofollow' to the links
    $content = str_replace('<a href="', '<a rel="nofollow" href="', $content);
    return $content;
}

I already tested this locally and it works fine.
this is the result of the tag cloud widget added in a sidebar

2. For the get_the_tags() function you can add this function:

add_filter('term_links-post_tag', 'add_nofollow_to_tag_list');
function add_nofollow_to_tag_list($tag_list) {
    $tag_list = str_replace('<a href="', '<a rel="nofollow" href="', $tag_list);
    return $tag_list;
}

The outcome will be the same:
This is the output of the tags from the get_the_tags function

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedueduedueduseduseduedueduedus