Jump to content

How to add Nofollow to the External URL but Not to Internal URL?

Recommended Posts

Site URL: https://www.philippinestravelguides.com/

Hi

I have used one of the code which explains how to make nofollow link on the website https://www.philippinestravelguides.com/ (Pass- HOPPFCL) now all URL's including my website Internal URL too has become nofollow.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$("a").attr('rel','nofollow');
});
</script>

What i noticed that squarespace use "Relative Link" instead of "Absolute Link" which the code cant identify internal vs external link so treating all link as external and marking them as nofollow.

So, I want to know how i can make my Internal Url's Dofollow. Need help on this..


Thanks

Link to comment
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Add this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() { 
$('a').attr('rel', function() {
  if(this.host == location.host) return '_dofollow'
  else return 'nofollow'
});
});
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.