1

Weebly unfortunately doesn't provide a way to make external links noFollow. I contacted them but to no avail then I looked for this script on the net.

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>

<script type='text/javascript'>
    //<![CDATA[
        jQuery('a').each(function() {
            // Let's make external links open in a new window.
            var href = jQuery(this).attr('href');
            if (typeof href != 'undefined' && href != "" && (href.indexOf('http://') != -1 ||
            href.indexOf('https://') != -1) && href.indexOf(window.location.hostname) == -1) {
                jQuery(this).attr("rel", "nofollow");
            }
        });
    //]]>
</script>

However, this code didn't work. Can you please tell me what's wrong or help me with a fix. Thank you.

Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101
jule morbe
  • 11
  • 1

1 Answers1

0

Weebly supports JavaScript, but has a bit of a different way of doing it than normal web hosts.

First, wrap your code in $(document).ready. Then, use the Custom HTML element to place the following code in your page:

<script type='text/javascript'>
    //<![CDATA[
        $(document).ready(function() {
            jQuery('a').each(function() {
                // Let's make external links open in a new window.
                var href = jQuery(this).attr('href');
                if (typeof href != 'undefined' && href != "" && (href.indexOf('http://') != -1 ||
                href.indexOf('https://') != -1) && href.indexOf(window.location.hostname) == -1) {
                    jQuery(this).attr("rel", "nofollow");
                }
            });
        }
    //]]>
</script>

As far as I can tell, Weebly already includes jQuery on the page for you, but if not, then go to Settings -> SEO and add the jQuery script tag. This will make it show up in your site <head> on Weebly.

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>
Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
  • Unfortunately, nothing worked so far. The code above didn't change anything. The links were still doFollow and even opening external link on external window never took place. I also added the jQuery script tag which messed up the whole site before I removed it. I appreciate your help, but so far weebly platform has been resisting all attempts. I don't know why? but I guess I will keep trying. – jule morbe Aug 10 '15 at 12:43