MozillaFoundation / foundation.mozilla.org

Mozilla Foundation website
https://foundation.mozilla.org
Mozilla Public License 2.0
379 stars 153 forks source link

Add "nofollow" links on blog posts #10678

Open jhonatan-lopes opened 1 year ago

jhonatan-lopes commented 1 year ago

Describe the feature request

Implement ability to add "no follow" (i.e. rel="nofollow"') to links in blog posts. Give editors the option of creating a new type of external link that has a rel="nofollow" property.

Some info on implementation can be found on https://github.com/wagtail/wagtail/issues/4474.

Additional context

Adding these links could help with traffic to blog posts.

┆Issue is synchronized with this Jira Task

victoriachan commented 1 year ago

It looks like it is not as straightforward as we had anticipated to allow editors to specify whether or not to use re="nofollow" on a link. The implementation suggestion on the issue above only works for applying the nofollow attribute to all external links indiscriminately, but not as an option.

If what we want is to have only add nofollow for links that are not affiliated with Mozilla (i.e. not from one of your other websites), then an alternative approach would be to have white list of domains, and we can match the link's href attribute against the white list, and only apply nofollow to links that do not match the white list.

There already is a hook to add target=_blank to external links on the current code. We can add to this hook our new conditional.

The benefit of this approach is that editors won't have to go through older blog post to retrospectively select each link to mark as nofollow. The rule will be automatically applied to all the external links on the site (not just blog) on rendering. There wouldn't be a database migration.

@mtdenton What do you think?

cdanfon commented 1 year ago

Hey @victoriachan Tyler is out until Wednesday. To avoid this from blocking you until then and knowing your last day for Moz is Thursday, please feel free to move forward with this approach.

victoriachan commented 12 months ago

The PR https://github.com/MozillaFoundation/foundation.mozilla.org/pull/10819 is ready for code review. For simplicity, I have added the whitelist as an env variable. This is a comma-separated list (no whitespace). The default value is "mozilla.org,mozilla.design", if not set.

victoriachan commented 12 months ago

@nickmoreton Are you able to review this please? Thank you!

simont-cr commented 4 months ago

@jhonatan-lopes I can see that the PR was not successfully merged with the rest of the code. Could you take a look and see if this ticket is considered as closed or if there's additional work to do?

jhonatan-lopes commented 4 months ago

Hey @simont-cr, we still need to do some work on this to be acceptable

simont-cr commented 4 months ago

Got it! I just updated the information so this is now a P2 ticket. Thank you!

data-sync-user commented 1 week ago

➤ Simon Acosta Torres commented:

Tyler Denton This issue ties with a PR Victoria on July 2023. Per Jhonatan’s latest comment, there was still work to be done on the PR to be acceptable and to close this ticket. Should we have one dev take a look in order to resolve or might not be as urgent as it once was?