Thanks for replying so quickly @RoryVB.
Unfortunately I’m seeing the same result even with the code just before the closing body tag.
Thanks for replying so quickly @RoryVB.
Unfortunately I’m seeing the same result even with the code just before the closing body tag.
You forgot the <script> tag ![]()
It should be like this:
$(document).ready(function() {
$("a").each(function() {
var url = ($(this).attr('href'))
if(url.includes('nofollow')){
$(this).attr( "rel", "nofollow" );
}else{
$(this).attr('rel','dofollow')
}
$(this).attr( "href",$(this).attr( "href").replace('#nofollow',''))
$(this).attr( "href",$(this).attr( "href").replace('#dofollow',''))
});
});
</script>
Thanks for spotting that. It doesn’t appear to have made any difference though! I’ve checked it a couple of times, using incognito etc.
Seems like something went wrong with the Quotation marks I quote copied from Raman
Try this:
$(document).ready(function() {
$("a").each(function() {
var url = ($(this).attr('href'))
if(url.includes('nofollow')){
$(this).attr( "rel", "nofollow" );
}else{
$(this).attr('rel','dofollow')
}
$(this).attr( "href",$(this).attr( "href").replace('#nofollow',''))
$(this).attr( "href",$(this).attr( "href").replace('#dofollow',''))
});
});
</script>
That’s done the trick, thank you! Final question, Raman said your code may not work in certain instances. Can I check does it mean if it works on my site, it should always work, or it could maybe not work intermittently? Thanks again, much appreciated.
Great!
He was talking about the code loading at the same time as the DOM, which could result in the code not finding the elements since that haven’t been loaded in yet. $(document).ready can help prevent this issue by waiting for the DOM to load first.
I have added this to my comment I made earlier. You’re fine!
Brilliant, thanks so much for your help on this, much appreciated.
Sounds like you got it working @GrahamCox. It really shouldn’t be as complicated as it is in Webflow, so in case anyone hasn’t been able to get it working I just added “rel=nofollow” as a free feature in the tool I’ve been building with Webflow’s new APIs:
Hopefully it’s helpful.
Hello, I’m trying this and can’t seem to get mine to work. I’ve added this code in my before body tag under the settings for my CMS template page. For the links in the rich text on the post that I want no follow, I’ve added #nofollow to the end of the URL. But I don’t se the rel=no follow on my published site in the code. Am I understanding this correctly? What am I doing wrong? Also, is there a way to hide the “#nofollow” in the actual URL?
This is the specific post: Chocolate Custard Brioche Donuts and the links I want no follow are the ones in the first paragraph and the recipe card, at the bottom of the page.
Any advice is appreciated!
Hey Rachel - looks like you’re most of the way there. You need to wrap the script with some tags so the browser knows it should run it as code (right now you can see it just thinks it’s text so it’s put it at the bottom of the page). Put <script> before the script and </script> after it and it should work. Let us know how it goes.
Definately looking for this.
Niels do you tend to use this selectively or for e.g. all external links?
And do you care about the ugc distinction?
I wish to do it selectively for low DA links but sadly can’t RN with webflow
The best solution I’ve found so far is to reverse proxy the site, and the add nofollow to links using a domain whitelisting approach.
The site’s own domain is whitelisted automatically, so anything to the current site, or to other domains you whitelist are “follow” and every other external link is “nofollow”.
Works well in my use cases but it doesn’t allow link-by-link control.
Hey Niels, yeah unfortunately it’s not supported by Webflow
I’ve seen a few people asking to selectively add rel=nofollow to links though, so I built it into fluidSEO. Happy to give you more info about it if you’d like.
Webflow added the rel attribute option in CMS Rich text links.
