Skip to content
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

Open
wants to merge 3 commits into
base: master
from

Conversation

@Xyfi
Copy link
Contributor

commented Jul 16, 2019

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?

  1. Add a link in any block that allows it.
  2. Enable the No Follow option. Save the post and see that a rel="nofollow" is added.
  3. Enable the Open in New Tab option. Save the post and see that the links now has the rel="noopener norefferer nofollow" attribute, aside from the aria-label and target attributes that are also added by the Open in New Tab option.
  4. Disable the No Follow option. See that the nofollow has been removed from the rel attribute.

Screenshots

Screenshot 2019-07-16 at 11 19 53

Types of changes

New feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

Fixes #13542

@Soean

This comment has been minimized.

Copy link
Member

commented Jul 16, 2019

Fixes #13542

@Xyfi Xyfi requested review from ajitbohra, gziolo, nerrad, ntwb and talldan as code owners Jul 16, 2019

@Xyfi Xyfi force-pushed the add/link-no-follow branch from b833de2 to fced87c Jul 16, 2019

if ( typeof rel === 'string' ) {
const noFollow = rel.split( ' ' ).includes( 'nofollow' );
if ( noFollow !== state.noFollow ) {
return { noFollow };

This comment has been minimized.

Copy link
@ellatrix

ellatrix Jul 24, 2019

Member

What if opensInNewWindow !== state.opensInNewWindow? Then noFollow won't be derived?

}
}

setNoFollow( noFollow ) {

This comment has been minimized.

Copy link
@ellatrix

ellatrix Jul 24, 2019

Member

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>

This comment has been minimized.

Copy link
@ellatrix

ellatrix Jul 24, 2019

Member

I don't see the attribute here.

@jphorn

This comment has been minimized.

Copy link

commented Aug 21, 2019

Why is noreferrer added automatically? This hurts affiliate marketing since all outbound nofollow clicks are non-trackable anymore. Could you please make it optional at least?

@paaljoachim paaljoachim referenced this pull request Aug 25, 2019
4 of 4 tasks complete
@paaljoachim

This comment has been minimized.

Copy link

commented Sep 4, 2019

What is needed to move this PR onward?
@Xyfi

@mapk

This comment has been minimized.

Copy link
Contributor

commented Sep 4, 2019

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?

@PhotoWorkout

This comment has been minimized.

Copy link

commented Sep 4, 2019

@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.
Now, with Gutenberg, you can only add a nofollow by switching to the HTML version and manually add the nofollow attribute. It's a big pain. I don't know how to best implement it (I am not a programer), but this is an important feature the Gutenberg editor should have.

@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).

@paaljoachim

This comment has been minimized.

Copy link

commented Sep 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.