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

102 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. Game online a lot of people who love to help them relieve stress of the moment, such as Tiny Tanks and Tiny Planes or Tiny Planes Beta is the fighting game with a pen or pencil, you have to destroy opponents before they kill you. Or Run 3 Unblocked and Hacked unblocked Gamesare skillful game controller for bears to dance to the goal without falling off a cliff. I wish you happy gaming!

    ReplyDelete
  5. I Will Provide SEO Blog Comment Service . & niche relevant blog comment service we provide a quality service with 100% Buyer satisfaction and My team Believed in Quality work not Quantity Contact me Now 24/7.check out this Blog for your business . your business will be gain 200% more profit I can not recommend you guys enough.

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

    ReplyDelete
  7. I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job! In my free time, I like play game: redball4games.com. What about you?

    ReplyDelete
  8. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete
  9. a pride for me to be able to discuss on a quality website because I just learned to make an article on
    cara menggugurkan kandungan

    ReplyDelete
  10. 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
  11. 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
  12. Buy Premium lawn Online for Women's at best prices available at Motifz. ✓ Latest Fashion, ✓ Trendy Designs ➤ Shop Now!

    ReplyDelete
  13. This website and I conceive this internet site is really informative ! Keep on putting up!
    Facebookvideodownloader.org
    Videodownloaderfb.com

    ReplyDelete
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. frases de buenos dias Actually its very nice site! this is my first visit on this site my friend gave the link of this site! and site is really great

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

    ReplyDelete
  23. 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
  24. The Digiexperts is one of the best digital marketing institutes in Delhi and all around India with its best teaching skills and Experts trainers includes all the skills and tactics such as email marketing best practices, benefits of video marketing,  types of facebook ads and all other basics at an affordable price with live experience in all topics.

    ReplyDelete
  25. 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
  26. 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
  27. intensity of your potential catchphrases and can help improve your internet searcher positioning especially in Google. blog comments service in 1$

    ReplyDelete
  28. This is really unbelievable and extraordinary work. Everyone should read. Thanks for sharing and don't miss WORLD'S BEST

    CarGames3dDownload

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

    ReplyDelete
  30. 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
  31. into clients. With powerful SEO content on your site, half of your web crawler rank enhancement work is finished. SEO service Pakisan

    ReplyDelete
  32. 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
  33. Packers And Movers Bangalore Local Household Shifting Service, Get Free Best Price Quotes Local Packers and Movers in Bangalore List, Compare Charges, Save Money And Time at
    Local Packers And Movers Bangalore

    ReplyDelete
  34. 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
  35. 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
  36. Wholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.

    ReplyDelete
  37. hy
    thanks for sharing this blog

    plz visit 123 Movies



    ReplyDelete
  38. 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
  39. 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
  40. Buy online wholesale lipstick boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

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

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

    ReplyDelete
  43. mylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  44. mylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  45. Thank you for sharing valuable information and useful post. I enjoyed reading this post and nice info always....@ Packers and Movers Ahmedabad

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

    ReplyDelete
  47. Great Article
    Cloud Computing Projects




    Networking Projects



    Final Year

    Projects for CSE





    JavaScript Training in Chennai



    JavaScript

    Training in Chennai




    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,

    Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.

    Angular Training

    ReplyDelete
  48. Blackbird packaging provide you with any size, shape design, custom cbd cream boxes sooner than any other packaging competitor in the market

    ReplyDelete
  49. 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
  50. Cookies Gelati 3.5g direct print mylar bag, available at Your Supplies. This bag comes with cookies holograms. Heat sealable. Fast Shipping.

    ReplyDelete
  51. 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
  52. custom printed printed mylar bags uk in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  53. Blackbird packaging provide you with any size, shape design, cbd vape oil boxes sooner than any other packaging competitor in the market

    ReplyDelete
  54. Get Packers and Movers Jaipur List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Jaipur Price Quotation instantly and Save Cost and Time. Packers and Movers Jaipur ✔✔✔Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @ Packers And Movers Jaipur

    ReplyDelete
  55. custom direct printed mylar bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  56. 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
  57. Thank you for sharing this article with us! I believe there will be more people like me, they can find many local packers movers
    I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post.
    Packers And Movers Jaisalmer
    Packers And Movers Jodhpur
    Click Here to Get More Sites
    Packers And Movers Jaipur

    ReplyDelete
  58. Blackbird packaging provide you with any size, shape design, custom cbd tincture boxes sooner than any other packaging competitor in the market

    ReplyDelete
  59. custom printed mylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  60. 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
  61. Nice image visibility and well written blog. Thanks for sharing. I have recently come across a new online service provider company which provides Shifting Services . @ Packers And Movers Bangalore

    ReplyDelete
  62. 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
  63. Packaging town is a one stop solution for the short-run tuck top boxes wholesale needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  64. 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
  65. buy grocery online in lahore from alfatah at best prices. get free shipping

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

    ReplyDelete
  67. 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
  68. You can book call girl in Guwahati or escort Service in Guwahati for incall facility
    or outcall Facility as and when required.To book Guwahati call girls you
    can visit the following links
    Guwahati Call Girl
    Call Girl in Guwahati

    ReplyDelete
  69. Hello, This is a Nitu roy very interesting blog. this content is written very
    well This is an amazing post, keep blogging.
    Guwahati Escorts
    Guwahati escort service

    ReplyDelete
  70. Diya Roy is a premier escort Service in Guwahati that provides call girl services
    or Call Girls in Guwahati hotels at cheap and affordable fixed rates.
    Call Girl in Guwahati
    Guwahati Call Girl

    ReplyDelete
  71. Explore the profiles of guwahati escorts, guwahati call girls, call girls in guwahati and
    escorts in guwahati for female companionship in top rated hotels.
    Get affordable escort services in guwahati hotels now.
    Guwahati call girls
    Call girls in Guwahati

    ReplyDelete
  72. I really loved your post so much that I cant resist writing comment...Please check mine as well
    Call girls in Bhubaneswar
    Bhubaneswar call girls

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

    ReplyDelete
  74. Blackbird packaging company can provide you with any size, shape design, and wedding cookie boxes wholesale sooner than any other packaging competitor in the market

    ReplyDelete
  75. Packaging town is a one stop solution for the short-run custom pillow boxes needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  76. Blackbird packaging company can provide you with any size, shape design, and bath bomb boxes sooner than any other packaging competitor in the market

    ReplyDelete
  77. Packaging town is a one stop solution for the short-run custom soap boxes needs and supplies. At affordable prices. Request a free quote now.

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

    ReplyDelete
  79. Packaging town is a one stop solution for the short-run custom soap boxes needs and supplies. At affordable prices. Request a free quote now.

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

    ReplyDelete
  81. Packaging town is a one stop solution for the short-run custom soap boxes needs and supplies. At affordable prices. Request a free quote now.

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

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

    ReplyDelete