# Rel=nofollow set for TrustLevel 3

**URL:** https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525
**Category:** Bug
**Created:** [11. August 2016 um 20:30 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525 "2016-08-11T20:30:33Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [11. August 2016 um 20:30 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/1 "2016-08-11T20:30:33Z")

</div>

Hi.

I noticed that on my forum a user with `user.has_trust_level?(TrustLevel[3]) == true` has rel=nofollow on their links. For example:

[https://forum.pololu.com/t/qik-2s9v1-red-led-on/10535/6](https://forum.pololu.com/t/qik-2s9v1-red-led-on/10535/6)

[https://forum.pololu.com/badges/3/leader](https://forum.pololu.com/badges/3/leader)

For the forum settings, I have “tl3 links no follow” unchecked, and “add rel nofollow to user content” checked, and “exclude rel nofollow domains” set to “[pololu.com](http://pololu.com)”.

The relevant code seems to be at [discourse/app/models/post.rb at e55e2aff94959aecc28095875f5de351de26162f · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/e55e2aff94959aecc28095875f5de351de26162f/app/models/post.rb#L206)

Currently our forum is on version `Version	v1.6.0.beta12 +7` and here is the current plugins we are using:

 ![](https://global.discourse-cdn.com/meta/original/3X/7/1/71bebe675e1b6802431274921ec43f60bafbc2fb.png)

Here is my Pry session trying to figure out what is going on:

```plaintext
[18] pry(main)> p = Post.where(id: 49157).first
=> #<Post:0x005580ef1f08b8
 id: 49157,
 user_id: 436,
 topic_id: 10535,
 post_number: 6,
 raw:
  "Based on the part that says `console=ttyS0,115200`, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik. I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:\n\nhttp://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\n\nPlease note that these instructions also involve disabling and Bluetooth and WiFi.\n\n--David",
 cooked:
  "<p>Based on the part that says <code>console=ttyS0,115200</code>, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik. I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:</p>\n\n<p><a href=\"http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\" class=\"onebox\" target=\"_blank\" rel=\"nofollow\">http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two</a></p>\n\n<p>Please note that these instructions also involve disabling and Bluetooth and WiFi.</p>\n\n<p>--David</p>",
 created_at: Wed, 03 Aug 2016 16:33:48 UTC +00:00,
 updated_at: Thu, 11 Aug 2016 20:21:40 UTC +00:00,
 reply_to_post_number: 5,
 reply_count: 0,
 quote_count: 0,
 deleted_at: nil,
 off_topic_count: 0,
 like_count: 0,
 incoming_link_count: 8,
 bookmark_count: 0,
 avg_time: 43,
 score: 33.75,
 reads: 8,
 post_type: 1,
 vote_count: 0,
 sort_order: 6,
 last_editor_id: 436,
 hidden: false,
 hidden_reason_id: nil,
 notify_moderators_count: 0,
 spam_count: 0,
 illegal_count: 0,
 inappropriate_count: 0,
 last_version_at: Wed, 03 Aug 2016 18:58:29 UTC +00:00,
 user_deleted: false,
 reply_to_user_id: 12636,
 percent_rank: 0.0,
 notify_user_count: 0,
 like_score: 0,
 deleted_by_id: nil,
 edit_reason: nil,
 word_count: 79,
 version: 2,
 cook_method: 1,
 wiki: false,
 baked_at: Thu, 11 Aug 2016 20:21:40 UTC +00:00,
 baked_version: 1,
 hidden_at: nil,
 self_edits: 3,
 reply_quoted: false,
 via_email: false,
 raw_email: nil,
 public_version: 2,
 action_code: nil>
[19] pry(main)> p.user.has_trust_level?(TrustLevel[3])
=> true
[20] pry(main)> SiteSetting.tl3_links_no_follow
=> false
[21] pry(main)> p.cooked.grep "nofollow"
NoMethodError: undefined method `grep' for #<String:0x005580ef22b850>
from (pry):21:in ` __pry__'
[22] pry(main)> p.cooked.include? "nofollow"
=> true
[23] pry(main)> p.rebake!
=> true
[24] pry(main)> p.cooked.include? "nofollow"
=> false
[25] pry(main)> p.save!
=> true
[26] pry(main)> p = Post.where(id: 49157).first
=> #<Post:0x005580ef89dcb0
 id: 49157,
 user_id: 436,
 topic_id: 10535,
 post_number: 6,
 raw:
  "Based on the part that says `console=ttyS0,115200`, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik. I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:\n\nhttp://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\n\nPlease note that these instructions also involve disabling and Bluetooth and WiFi.\n\n--David",
 cooked:
  "<p>Based on the part that says <code>console=ttyS0,115200</code>, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik. I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:</p>\n\n<p><a href=\"http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\" class=\"onebox\" target=\"_blank\" rel=\"nofollow\">http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two</a></p>\n\n<p>Please note that these instructions also involve disabling and Bluetooth and WiFi.</p>\n\n<p>--David</p>",
 created_at: Wed, 03 Aug 2016 16:33:48 UTC +00:00,
 updated_at: Thu, 11 Aug 2016 20:24:29 UTC +00:00,
 reply_to_post_number: 5,
 reply_count: 0,
 quote_count: 0,
 deleted_at: nil,
 off_topic_count: 0,
 like_count: 0,
 incoming_link_count: 8,
 bookmark_count: 0,
 avg_time: 43,
 score: 33.75,
 reads: 8,
 post_type: 1,
 vote_count: 0,
 sort_order: 6,
 last_editor_id: 436,
 hidden: false,
 hidden_reason_id: nil,
 notify_moderators_count: 0,
 spam_count: 0,
 illegal_count: 0,
 inappropriate_count: 0,
 last_version_at: Wed, 03 Aug 2016 18:58:29 UTC +00:00,
 user_deleted: false,
 reply_to_user_id: 12636,
 percent_rank: 0.0,
 notify_user_count: 0,
 like_score: 0,
 deleted_by_id: nil,
 edit_reason: nil,
 word_count: 79,
 version: 2,
 cook_method: 1,
 wiki: false,
 baked_at: Thu, 11 Aug 2016 20:24:29 UTC +00:00,
 baked_version: 1,
 hidden_at: nil,
 self_edits: 3,
 reply_quoted: false,
 via_email: false,
 raw_email: nil,
 public_version: 2,
 action_code: nil>
[27] pry(main)> p.cooked.include? "nofollow"
=> true

```

When I call `rebake!` on the post, it does not have the “nofollow” but when I save it and reload it from the database, it does.

Ryan

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [11. August 2016 um 21:29 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/2 "2016-08-11T21:29:36Z")

</div>

Possibly a bug, @eviltrout can have a look tomorrow.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [12. August 2016 um 04:50 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/3 "2016-08-12T04:50:57Z")

</div>

What happens if you rebake with the “Rebuild HTML” button in the menu for the post?

---

<div class="post-metadata">

### Author: ![TechnoBear](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/technobear/32/40546_2.png) [@TechnoBear](https://meta.discourse.org/u/TechnoBear)
#### Post date: [12. August 2016 um 14:31 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/4 "2016-08-12T14:31:15Z")

</div>

We upgraded to latest overnight, and I notice that links in my posts there are now “nofollow” - and I’m TL4. I don’t know for certain, but I’ll be very surprised if any settings were deliberately changed.

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [12. August 2016 um 14:42 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/5 "2016-08-12T14:42:20Z")

</div>

Good question. It keeps the rel=nofollow in there. (That was the first thing I tried, but I forgot to mention it!)

---

<div class="post-metadata">

### Author: ![TechnoBear](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/technobear/32/40546_2.png) [@TechnoBear](https://meta.discourse.org/u/TechnoBear)
#### Post date: [12. August 2016 um 14:53 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/6 "2016-08-12T14:53:46Z")

</div>

Now I look, my links and @cpradio’s links in this topic are “nofollow”, but we’re both TL3 here.

[https://meta.discourse.org/t/confused-about-the-nice-share-badge/43180/3](https://meta.discourse.org/t/confused-about-the-nice-share-badge/43180/3)

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [12. August 2016 um 17:41 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/7 "2016-08-12T17:41:41Z")

</div>

I’ve noticed that with my links as well.

Personally, I don’t care a whit whether or not any links I post are nofollow or not.

I assumed the Setting had been changed and have not checked on my localhost (yet).

If the Setting hasn’t been changed and it is a bug I imagine there will be a lot of members that do w ant this “perk”.

EDIT  
Just checked on localhost with a TL3 members post.  
I don’t know why the “onebox” is there, but there isn’t a “nofollow”

```plaintext
<a href="https://www.google.com/" 
class="onebox" target="_blank">
https://www.google.com/
</a>

```

EDIT  
Spoke too soon, nofollow is there now.  
(a delayed onebox thing?)

```plaintext
<a href="https://www.google.com/" 
class="onebox" target="_blank" 
rel="nofollow">
https://www.google.com/
</a>

```

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [12. August 2016 um 18:50 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/8 "2016-08-12T18:50:09Z")

</div>

It seems to involve this Setting

> add rel nofollow to user content  
> Add rel nofollow to all submitted user content, except for internal links (including parent domains). If you change this, you must rebake all posts with: “rake posts:rebake”

With that disabled links do not get a rel nofollow.

With it enabled, links get a rel nofollow regardless of the TL3 setting.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [12. August 2016 um 19:36 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/9 "2016-08-12T19:36:25Z")

</div>

I found a bug in our post processing code where `nofollow` was being applied by mistake. Here’s a fix:

[https://github.com/discourse/discourse/commit/aef954784a99f27e799c193e7e15aefbc2083c82](https://github.com/discourse/discourse/commit/aef954784a99f27e799c193e7e15aefbc2083c82)

It will require a rebake for the posts where the bug applies though ☹

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [19. August 2016 um 22:05 UTC](https://meta.discourse.org/t/rel-nofollow-set-for-trustlevel-3/48525/10 "2016-08-19T22:05:48Z")

</div>


