-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added nofollow option for links #16609
Conversation
Fixes #13542 |
b833de2
to
fced87c
Compare
if ( typeof rel === 'string' ) { | ||
const noFollow = rel.split( ' ' ).includes( 'nofollow' ); | ||
if ( noFollow !== state.noFollow ) { | ||
return { noFollow }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if opensInNewWindow !== state.opensInNewWindow
? Then noFollow
won't be derived?
} | ||
} | ||
|
||
setNoFollow( noFollow ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much the same as the code above. Could similar logic be merged?
|
||
exports[`Links should contain a nofollow rel attribute when the option is selected 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>This is <a href=\\"http://w.org\\">WordPress</a></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the attribute here.
Why is |
What is needed to move this PR onward? |
I’m hesitant on this one. I think it’s been a long-standing discussion and there are reasons behind not including this option in the Classic Editor. How does it adhere to the WordPress 80/20 rule? We’re looking to implement this as an option (not a decision)… so will 80% of WP users benefit from it? |
@mapk I don't know the "reasons behind not including this option in the Classic Editor", but installing a nofollow plugins like this one: https://wordpress.org/plugins/rel-nofollow-checkbox/ made it easy to add a no follow checkbox in the classic editor. @jphorn I don't see a problem with the norefferer being there automatically, it does not hurt in terms of tracking affiliate referrals (norefferer does not equal non-trackable). |
As there is hesitation in adding this into Gutenberg Core then there needs to be a simple way for plugins to extend the link dialog box. (I have no idea if a plugin developer can extend the link dialog box in Gutenberg at present time.) If this is it not available today then someone needs to create an issue and someone needs to work on the PR to get it in. |
@paaljoachim I've just gone ahead and added this option to EditorsKit plugin( https://wordpress.org/plugins/block-options/ ). I've added the new "sponsored" rel attribute value as well. Thanks for letting me know about this one 👍 |
💯 Agree on this. What @phpbits has done, probably works. But seems like he has un-registered the existing I would like to avoid that approach because that will raise the tech debt on the plugin developer's end and they would have to maintain their copy of link format. If the link dialog box can provide certain hooks/filters, then plugin developers can use them to extend the existing link format. So that they don't have to maintain their copy of link format in their codebase. Figuratively, There's no point of maintaining two wheels to run a cycle in the same direction. |
@desaiuditd I've actually found a simpler approach but chose to this in order to support the core editor version. I hope they'll add much easier filter though. |
@mapk I cannot understand if this feature will not be included in Core of Block Editor. And I believe hosts of other users would also not understand. It is a different situation than with Classic Editor: the HTML switch in Classic was usable. But if those content editors never have a chance of adding/removing/tweakin the rel attribute for nofollow or other attributes then this would be really, really bad. The promise of Gutenberg is to make things more easy and more simple after all - at least how I understand it, and I assume millions of other users also. I can only encourage you, leave some of the old ballast of Classic-Editor-Discussions from 10 years ago behind. If it makes sense for a lot of users to be able to tweak the nofollow attribute they should be able to do it - easily. And if you decide to not include this option/feature - then please make it easy for plugin devs to extend this area of Gutenberg. So that we can at least get simple awesome plugins and NO hacky solutions. Thanks a lot in advance for listening to your user and developer base! |
Nofollow, for Google and W3 is a rel to identify paid links. Stop. Not all WordPress user sell links, normally link to other websites, why dont send autority to links? Not good/non sense implementation. |
Any serious webmaster (and content writer) should have the ability to manage outgoing links fast. Unless you are a hobby blogger, you will come across links which need special attribution. |
@PhotoWorkout, yes, but, if now exist rel="sponsored" why add rel="nofollow"? If i don't trust website i won't link. But, the main "problem" is: WordPress is used by 24,808,989 websites, not all is "serious" webmasters, why add a not long term function (nofollow) only for few people? Use a plugin. Bye, |
The rel=“sponsored” is currently only used by Google. Other search engines like Bing don’t (they probably will in future). So for now the right way would be to add both (rel=“sponsored nofollow”). I believe Wordpress.org should make rel link attribute selection a core part of Gutenberg editor. You wouldn’t even see those link rel options if you don’t expand your link options, adding two on/off toggles in addition to the “Open in a new window” toggle is not going to harm the user experience. |
Agree with this (if is accesible), but IMHO is useless, advanced webmaster/i if want add nofollow and other code add in code editor with Gutenberg. |
@phpbits your EditorKit plugin works just fine. This seems to be the best solution (at least for now) Thanks! |
Someone adding a link wants to do just that, by adding more and more options we put extra hurdles in their way to add that link. Having to explain those hurdles adds more and more weight. For me, this comes down to being something that would be ok to have extendable by developers but not visible in the default interface. |
So much effort went in to provide a logical and workable solution yet Wordpress core team ignoring the blatantly obvious need for this. All websites from blogs to publishers of all sizes needs this. Please get this implemented we NEED IT! |
WTF?! Could someone just make a plugin out of this? |
There is, you can use EditorsKit plugin. |
The EditorsKit plugin does not work for me as afer install on a few sites you cannot edit posts it crashes. |
AIOSEO also has it now. |
I initially didn't want to use your plugin because it wasn't adding the rel tags into the actual HTML code. That meant if the plugin ever broke, the links would be dofollow until it was fixed. But I've just tried it again recently. I made a link with nofollow, deleted your plugin completely, and nofollow remained in the HTML. Can you confirm that's what it's doing now, @phpbits ? Because that's what I had with Ultimate Nofollow in classic editor that seemed to be impossible in Gutenberg. Either way, your plugin has come a long way and is now making Gutenberg tolerable for me. I'm never going to like a block editor for my purposes, but EditorsKit fixes a lot of what was adding so much time to my workflow (not just the nofollow links). |
It is now built in and part of Yoast SEO so you can mark it sponsored and nofollow and it's in the editor so a permanent change in the actual html |
Then it must be possible to do that now. Good to know. I don't use Yoast, but good for those who do. |
Description
Adds a "nofollow" option for links allowing the author to discourage search engines from following links.
This is an alternative for #13190 which was overly complicated. Also because of #13190 (comment).
How has this been tested?
No Follow
option. Save the post and see that arel="nofollow"
is added.Open in New Tab
option. Save the post and see that the links now has therel="noopener norefferer nofollow"
attribute, aside from thearia-label
andtarget
attributes that are also added by theOpen in New Tab
option.No Follow
option. See that thenofollow
has been removed from therel
attribute.Screenshots
Types of changes
New feature
Checklist:
Fixes #13542