ideas
ideas copied to clipboard
Add optional rel field for Bard Links
Currently nofollow links on Bard is either all-in or all-out.
It would be helpful to be able to specify this on a per-link basis. Using a text input would allow setting nofollow, sponsored, etc. As an example:

I was thinking sort of the same thing, but instead of having link_noreferrer, link_nooperner and target_blank a toggle with true/false, change it to be a radio of true/false/external so internal links and assets are left as they are, but external links default to open in a new window with proper SEO rel value.
@jeremydouglas did you implement a solution yourself in the end?
This would be super useful. Is there an example implementation anywhere?
We ended up doing it ourselves using the jacksleight/statamic-bard-mutator package:
Mutator::html('link', function ($value) {
$href = $value[1]['href'] ?? null;
if (URL::isExternal($href) && !Str::startsWith($href, ['mailto:', 'tel:'])) {
$value[1]['rel'] = 'external noopener';
$value[1]['target'] = '_blank';
}
return $value;
});
Thanks, this is helpful! I also found a way by using https://jacksleight.dev/docs/bard-texstyle/attributes but it feels a bit clunky as it's being set in a separate button in the toolbar... and to get this you need the pro version. I'll see if I can achieve this directly in the link button in Bard.