find a location for property in a new city

Friday 11 January 2013

Add rel="nofollow" to all external links with one line of jQuery

You may want to change all external links on a page to do something different such as add a target="_blank" to each one or add rel="nofollow" to every external link. This post will show you how this can be done in one line of jQuery!

SEO SEO SEO... How tiresome a concept... Anyway, people make their living with it apparently and while that is the case I get all kinds of weird requirements like this. This time I had to add rel="nofollow" to all external links for latest whim of an SEO consultant.

Since SEO requirements seem to chop and change fairly unpredictably I wanted to add rel="nofollow" to all external links in the quickest and least interfering way possible. I managed it with one line of jQuery so that is fairly innocuous and I can just remove it if it needs to be undone at some point. This can be used to add target="blank" to also.

Add rel="nofollow" to all external links

$("div.content a[href^='http']:not([href*='mysite.co.uk'])").attr("rel", "follow");

Add target="_blank" to all external links

$("div.content a[href^='http']:not([href*='mysite.co.uk'])").attr("target", "_blank");

Hope this helps you spend as little time on this as possible :)

Update:

I did some reasearch into whether adding a nofollow in this way will work on Google and came to the conclusion that it probably wont. Colin Asquith commented similar thoughts. So this should probably be considered if using this for adding rel="nofollow" to links but technically this is a good way of going about it or anything similar like adding target="_blank" for example.

Follow britishdev on Twitter

99 comments:

  1. But doesn't this just add "nofollow" to links using JavaScript after the page has loaded? When a bot spiders your page it will actually get the links before they have had this attribute added, so will be treated as normal links.

    Basically if you have a website, and it's built up some credibility, sites you link out to get some of that - so often you want to use "nofollow" for something like a comments page so when people add links in comments they aren't doing it for their own SEO benefit.

    ReplyDelete
    Replies
    1. You know what? I think you're on to something. I actually looked into this myself as you can never be sure how Google works since it apparently does execute JavaScript. I came to the definitive solution that it *probably* wont work in the way I intended. As in it will affect the DOM but it will *probably* be too late for Google to care.

      However, I forgot I wrote a blog post about it so I should probably correct that.

      Delete
  2. Also- a pleasure to see a .NET/SQL blog by a fellow developer and a fellow Colin :) we're taking over.

    ReplyDelete
  3. I am pleased to read about no follow link,i have got useful information.I will come back to read more articles.
    gym mats are flexible buy them from http://rubbergymflooringco.co.uk/gym-mats.html

    ReplyDelete
  4. I have got useful information,thanks for sharing.
    gclub
    golden slot
    gclub casino

    ReplyDelete
  5. I've talked a lot about anchor text lately in terms of how important it is to vary up the anchor text which you use when creating links to your site.url shortener for twitter

    ReplyDelete
  6. Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.

    ReplyDelete
  7. Coffee Grinders & Espresso Makers Prices in United State as on 26-Jul-2016. Find Latest Models, Best Prices, Genuine Products ninja coffee bar system, Top Brands and Stores for Coffee .

    ReplyDelete
  8. Nothing compares to Weber using Genesis sort of grills. That is certainly the type gas grills which have been that will always make sure that they deliver a high performance part of down interval event coordinator companies

    ReplyDelete
  9. I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you! mankhatri885

    ReplyDelete
  10. Wow… all design is superb and attractive. I loved them. Thank you for sharing this blog online. Great Designs ever. We also provide stitch gold embroidery designs.For this you can get your membership today.

    ReplyDelete
  11. Nothing compares to Weber using Genesis sort of grills. That is certainly the type gas grills which have been that will always make sure that they deliver a high performance part of down interval alinshop buy domestic USA

    ReplyDelete
  12. That is why it can be more effective that one could essential investigation in advance of making. You'll be able to write increased content using this method. microsoft office 365 product key

    ReplyDelete
  13. Great things you’ve always shared with us. Just keep writing this kind of posts.The time which was wasted in traveling for tuition now it can be used for studies.Thanks naps-gear.org

    ReplyDelete
  14. Explore classic and modern necklace for women and pendants, including diamond drop necklace for women, charm necklaces in silver and gold

    ReplyDelete
  15. This is the best website i have visited about child care.You have work hard in making this post. Search webstagram to discover photos and videos on instagram,

    ReplyDelete
  16. you have to pick important web journals to offer remarks to include something, which is viewed as helpful to the post. To put it plainly, blog comment service

    ReplyDelete
  17. The article was extraordinary and has all the data about SEO that one needs. Every one of the clients ought to value your post. top seo agency, SEO for Dentist

    ReplyDelete
  18. intensity of your potential catchphrases and can help improve your internet searcher positioning especially in Google. blog comments service in 1$

    ReplyDelete
  19. the venture similarly as costly as, or considerably increasingly costly, than running it through a top level organization. Brand Identity Design

    ReplyDelete
  20. advancement and web based promoting administrations, is the manner by which to seclude the 'right' specialist co-op from the thousands in the market. hearthstone coaching

    ReplyDelete
  21. into clients. With powerful SEO content on your site, half of your web crawler rank enhancement work is finished. SEO service Pakisan

    ReplyDelete
  22. i never know the use of adobe shadow until i saw this post. thank you for this! this is very helpful. ufabet.win/àžšàžČàž„àžČàžŁ่àžČ-sa-game-66

    ReplyDelete
  23. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free off page SEO

    ReplyDelete
  24. Wow..!! Thank you! Superb Information I always wanted to write on my cash for cars website something like that. Can I consist of a portion of your post to my website.

    ReplyDelete
  25. Buy online wholesale printed custom candle boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

    ReplyDelete
  26. Buy online wholesale printed lipstick boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

    ReplyDelete
  27. Buy online wholesale lipstick boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

    ReplyDelete
  28. Blackbird packaging provide you with any size, shape design, CBD boxes sooner than any other packaging competitor in the market

    ReplyDelete
  29. Packaging town is a one-stop solution for the short-run Custom Packaging, Wholesale CBD Boxes needs, and supplies at ease.

    ReplyDelete
  30. Packaging town is a one stop solution for the short-run tab lock tuck top mailing boxes needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  31. Cookies Gelati 3.5g direct print mylar bag, available at Your Supplies. This bag comes with cookies holograms. Heat sealable. Fast Shipping.

    ReplyDelete
  32. Gas Co Gelato 33 3.5g Direct Print on the front and back. % Cali Packs Available at Your Supplies. Heat sealable mylar bags. Fast Shipping.

    ReplyDelete
  33. Packaging town is a one-stop solution for the short-run business card boxes wholesale needs, and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  34. Packaging town is a one stop solution for the short-run kraft business card boxes needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  35. Blackbird packaging company can provide you with any size, shape design, and crafted cbd bath bombs wholesale sooner than any other packaging competitor in the market

    ReplyDelete
  36. buy sweatshirts for men online from wild goat clothing

    ReplyDelete
  37. lahore electronics
    Shop for Electronic Goods at Al-Fatah, Pakistan's leading chain of departmental stores. Shop from a huge range of top brands Home Appliances, Smart-tech and Phones and Sound bars from Al-Fatah. Shop from huge range of electronics available at Al-Fatah. Avail Free Delivery on orders above 1000 PKR in selected cities.

    ReplyDelete
  38. buy grocery online in lahore from alfatah at best prices. get free shipping

    ReplyDelete
  39. buy cbd vape cartridge packaging from blackbird packaging at best prices. Get free shipping.

    ReplyDelete
  40. Blackbird packaging company can provide you with any size, shape design, and wholesale cbd bath bombs sooner than any other packaging competitor in the market

    ReplyDelete
  41. Thanks For Sharing This Comment Very Authentic Reason for the Article.
    Technology news Pakistan

    ReplyDelete
  42. Buy lawn collection 2021 from Ilaha Clothing at best prices. Get Free shipping.

    ReplyDelete
  43. This comment has been removed by the author.

    ReplyDelete
  44. Your article is very helpful. It's an amazing information. you can change your website direction through SEO Service Mumbai

    ReplyDelete
  45. buy cookie packaging wholesale online from Blackbird Packaging at best prices. Get free shipping

    ReplyDelete
  46. buy baby care product in pakistan from medisense at best prices. Get free shipping

    ReplyDelete
  47. buy leggings for women online from dshred at easy prices at your doorstep. get free shipping.

    ReplyDelete
  48. It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read. Get for more information online casino real money

    ReplyDelete
  49. buy leggings for women online from dshred at best prices. Get free delivery

    ReplyDelete
  50. buy tanks top for men online from Dshred at easy prices delivered at your doorstep. Get free shipping

    ReplyDelete
  51. buy insulins online pakistan at best prices from medisense delivered at your doorstep. Get free delivery

    ReplyDelete
  52. buy dental care products online from Medisense.pk delivered at your doorstep at best prices. Get free shipping

    ReplyDelete
  53. buy mesh bra for women online from dshred at easy prices delivered at your doorstep.get free shipping.

    ReplyDelete
  54. buy beauty makeup in lahore from alfatah at best prices delivered at your doorstep. get free delivery

    ReplyDelete
  55. buy baby care products online from medisense at best prices deloivered at your doorstep. get free shipping

    ReplyDelete
  56. Buy all kind of medicine online pharmacy in lahore at easy prices from medisense delivered at your doorstep. Get free shipping.

    ReplyDelete
  57. buy reflective vest online from dshred at easy prices delivered at your doorstep. get free shipping

    ReplyDelete
  58. buy gym leggings online from Dshred at best prices delivered at your doorstep. get free shipping

    ReplyDelete
  59. NDURE presents the ultimate fashion formula for men in the form of men's shorts. Get the best chino shorts from NDURE that are not only sports shorts but also great for everyday wear. Our wide range of shorts for men is crafted keeping in mind your comfort. So shop online to get your hands on the best shorts in Pakistan.

    ReplyDelete
  60. The most important things when working out are flexibility and comfort. That is why Dshred has the best collection of Women’s Bottoms and Joggers to suit your needs. We have the best leggings for women and girls in Pakistan. Get high-quality gym trousers and yoga pants to suit your workout needs.

    ReplyDelete
  61. buy sports bra online in Pakistan from dshred at easy prices delivered at your doorstep. Get free shipping

    ReplyDelete
  62. buy electronics online from Al-Fatah at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  63. Buy electronics online in Pakistan from Al-Fatah at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  64. Buy electronics online in pakistan at best prices from Al-Fatah delivered at your doorstep. Get free shipping

    ReplyDelete
  65. Buy grocery online in Pakistan at best prices delivered at your doorstep. get free shipping

    ReplyDelete
  66. I was searching for many blogs site and now finally I have got this cool place with lots of information
    Father George Rutler

    ReplyDelete
  67. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post.
    Father George Rutler

    ReplyDelete
  68. I am excited about this external link of the one-line query. I will try it on my computer. whatsapp mod

    ReplyDelete
  69. Jazmin offers an amazing chiffon collection of ladies dresses, including maxi dresses and wedding dresses. Grab their stylish and trendy new bridal dresses and wedding dresses online today. These chiffon dresses for women designs are sure to bring attention and improve your wardrobe. Jazmin offers the best ladies maxi dresses in their Chiffon collection.

    ReplyDelete
  70. Exit the Gungeon is a dungeon crawler, or climber, that is extremely cumbersome and prey. The game continues immediately after the events of Enter the Gungeon, following the search for "Gungeoneers" in the Gungeon itself. The "Gungeoneers" finally entered the Gungeon, but they quickly realized that it had become a paradox and was falling apart. Players must fight enemies during an elevator ride and constantly hitman absolution Game download adobe premiere elements cracked sketchup with crack Redream Activation Code AVG Antivirus License key Best 24 Korean Action Movies bandicut keygen designdoll license key epubor crack xsplit premium license keyrooms to finally escape. All the things that I loved about Enter the Gungeon remain; collecting wonderful and interesting weapons, hundreds avoided by bullets, wonderful but incredibly difficult bosses; everything is still there, with a few small modifications to bring it to life. Perhaps the biggest change is the battlefield itself. You will spend most of your time avoiding bullets in a very limited space elevator - defeat all these enemies and you will enter the next floor until you enter the elevator again and again.

    ReplyDelete
  71. Websites should be designed in such a manner that they can effectively send across your message to your target audiences with no hassles. If your site is attractive and effective, more number of users will attract towards your site and from this a growing number of number of people may come to learn about your goods and solutions. telenor rs

    ReplyDelete
  72. Highway Fashion Offering sale on brands. View Featured Sales around you and order now the best women clothing deals.

    ReplyDelete
  73. Many company websites are simply an online brochure. You can rest assured that Google pays careful attention to what is on a site and ranks sites accordingly. In order to leverage the power of the Internet, you need to ensure that your site is updated with fresh content on a regular basis. Additionally, your content needs to be optimized to contain relevant keywords for which you want your website to be found. Website Design Company Dubai

    ReplyDelete
  74. ECS is offering best bridal shoes which are premium quality product and trendy in design.

    ReplyDelete
  75. acunetix crackAcunetix Crack regulator approves and finds potentially dangerous HTTP technologies that can be dynamic on the target web worker.cloud meadow pc downloadPort scanning is anotherconstruct 2 crackactivity that you can try with this app because in such a case it tracks an open entry. It is will quickly start network security investigation from conceivable interrupt flag.adobe acrobat pro dc crack

    ReplyDelete
  76. Mailbird Pro is built with a host of apps, shortcut enhancements, and more for these features. Mailbird Pro Crack It consists of many types of applications, such as social networking applications Amplitube Serial Number that help you effectively plan the marketing communications you need.adobe indesign serial number The main goal of these features is to bring all email and messaging applications together in one platform. Long Lasting Citrus Perfume You could use it and cause problems with your travel email information. what happens if your ankle monitor died

    ReplyDelete
  77. duplicate finder crack comes with a quick setup process, which even offers a fairly fast scanning algorithm. silhouette studio crack comes with a powerful scanner that scans all the folders and files on the hard drive. And idm crack also locates duplicate data files. You can delete documents, images, sound, videos, and data from your computer system. Its custom scanner allows end users to determine the size and classification of files, which can help find and classify files.

    ReplyDelete
  78. prism video converter crack custom scanner allows end users to determine the size and classification of files, which can help find and classify files.

    ReplyDelete

  79. I am very happy to read this article. Thanks for giving us Amazing info. Fantastic post.
    Thanks For Sharing such an informative article, Im taking your feed also, Thanks.character creator 3 free download

    ReplyDelete
  80. Online Pakistani bridal lehnga sale is one of the best online shopping website in Karachi. Find Bridal Lehngas, Saree, Formal Wear, Party Wear and Wedding Dress for Women at best price .
    Online Saree in Pakistan

    ReplyDelete
  81. Want To Approach An Affordable Garage Door Installation Arkansas? Feel Free To Call Us, As We Provide You With Professional Services In This Matter. Whether Your Door Is Misaligned, Broken, Or Their Springs Or Cables Are Not Doing Well, We Can Fix It For You.

    ReplyDelete
  82. This comment has been removed by the author.

    ReplyDelete
  83. This comment has been removed by the author.

    ReplyDelete
  84. This comment has been removed by the author.

    ReplyDelete
  85. Since SEO requirements seem to chop and change fairly unpredictably
    visit link my websiteTel-U

    ReplyDelete