I'd had a query raised by an SEO consultant and I'm unable to see a way to achieve what he is after.
Basically, when rendering any outbound links they are after the option (ideally with a flag of some sort) to say if the link should have a "nofollow" rel tag added to it. Now, I could create a custom property editor but this wouldn't allow it to work in RTE's which is where most of the links exist.
Has anyone had this requirement before and found a way to achieve it?
I haven't had that requirement myself, but thinking about potential solutions.
There's either the - take a sledgehammer to crack a nut, or a more granular approach.
The sledgehammer one would be a custom HttpModule filter that would parse the response stream, figure out which links we external and modify the markup. Sounds full on, but it'd cover any gotchas.
The granular approach would be to look at how the links are getting rendered. For things like content pickers (and other community property-editors), then those will be rendered in templates - so you control the markup.
As for the RTE, as you say, it's problematic.
For that I'd look at making a custom override for the RteMacroRenderingValueConverter value-converter. This is used to parse all the internal links/macros. You could override either the ConvertDataToSource or ConvertSourceToObject methods (important to remember to call the base methods), and add whatever custom code you'd need to add the "rel=nofollow" tags.
Cheers for the ideas Lee. Yeah for the content pickers/link pickers that aren't part of the RTE it's not to bad. Although what I'm ideally after is a checkbox for the editor to flag if the rel tag should be added or not on a per link basis.
Now I could use nested content to wrap all these property editors but it feels like overkill in my opinion.
I'm wondering if this is more something that should be looked as an improvement for the property editors (maybe a PR) where there are configurable options such as adding an anchor link or a query string to links, plus the option to add checkboxes for these sorts of things. Although we don't want to make the link pickers too complicated.
I guess part of my question is also how many people have had this requirement?
My initial thoughts are it sounds like a lot of work to work around existing implementations for something that might have a minimal impact especially when it's not for all external links but just some.
Gotcha. I'd expect many devs to make a site-wide assumption, e.g. external URL = "nofollow". But understand the need for granular control.
I know what you mean with the property-editors, how to tackle adding more meta-data about the link itself, (e.g. many of the link pickers have a "open in new window" checkbox).
NC would work, but yeah feels overkill - and wouldn't cover links in RTEs. Hmmm.
Interested to hear if/how others have tackled this requirement too.
Hi Guys - did you manage to come across a suitable solution for this? I've just had a requirement in asking to add nofollow but only to specific links the client chooses - at the moment i'm looking around to see how others have done it :-)
Just to let you know, No I didn't ever get a solution that worked for this and at the time the client dropped the requirement so I forgot all about it. Really it needs some PR's to core so would need discussions with HQ to really consider how best to handle it IMO :-)
We tend to use HtmlAgilityPack for stuff like this to clean/parse and process stuff.
Something like:
var doc = new HtmlDocument();
doc.LoadHtml(html);
var nc = doc.DocumentNode.SelectNodes("//a");
if (nc != null)
{
foreach (var node in nc)
{
// Do stuff
}
}
string res = doc.DocumentNode.InnerHtml;
Umbraco - Link configurations
Hi All,
I'd had a query raised by an SEO consultant and I'm unable to see a way to achieve what he is after.
Basically, when rendering any outbound links they are after the option (ideally with a flag of some sort) to say if the link should have a "nofollow" rel tag added to it. Now, I could create a custom property editor but this wouldn't allow it to work in RTE's which is where most of the links exist.
Has anyone had this requirement before and found a way to achieve it?
Thanks,
Nik
Hi Nik,
I haven't had that requirement myself, but thinking about potential solutions.
There's either the - take a sledgehammer to crack a nut, or a more granular approach.
The sledgehammer one would be a custom HttpModule filter that would parse the response stream, figure out which links we external and modify the markup. Sounds full on, but it'd cover any gotchas.
The granular approach would be to look at how the links are getting rendered. For things like content pickers (and other community property-editors), then those will be rendered in templates - so you control the markup.
As for the RTE, as you say, it's problematic.
For that I'd look at making a custom override for the
RteMacroRenderingValueConverter
value-converter. This is used to parse all the internal links/macros. You could override either theConvertDataToSource
orConvertSourceToObject
methods (important to remember to call the base methods), and add whatever custom code you'd need to add the "rel=nofollow" tags.Hope this helps?
Cheers,
- Lee
Cheers for the ideas Lee. Yeah for the content pickers/link pickers that aren't part of the RTE it's not to bad. Although what I'm ideally after is a checkbox for the editor to flag if the rel tag should be added or not on a per link basis.
Now I could use nested content to wrap all these property editors but it feels like overkill in my opinion.
I'm wondering if this is more something that should be looked as an improvement for the property editors (maybe a PR) where there are configurable options such as adding an anchor link or a query string to links, plus the option to add checkboxes for these sorts of things. Although we don't want to make the link pickers too complicated.
I guess part of my question is also how many people have had this requirement?
My initial thoughts are it sounds like a lot of work to work around existing implementations for something that might have a minimal impact especially when it's not for all external links but just some.
Gotcha. I'd expect many devs to make a site-wide assumption, e.g. external URL = "nofollow". But understand the need for granular control.
I know what you mean with the property-editors, how to tackle adding more meta-data about the link itself, (e.g. many of the link pickers have a "open in new window" checkbox).
NC would work, but yeah feels overkill - and wouldn't cover links in RTEs. Hmmm.
Interested to hear if/how others have tackled this requirement too.
Cheers,
- Lee
Hi Guys - did you manage to come across a suitable solution for this? I've just had a requirement in asking to add nofollow but only to specific links the client chooses - at the moment i'm looking around to see how others have done it :-)
Si
Hi All,
I just had the same request from a client.
It seems like there could be other attributes but rel="nofollow" is just the most requested one that isn't handled by the RTE or link picker.
One thought is to tell them to use the
View Source Code
button on the RTE.I've created a feature request to see if this is a desirable feature. https://github.com/umbraco/Umbraco-CMS/issues/10051
Just wait until the client's SEO agency ask about the
noreferrer
andnoopener
values too. 😁Hi All,
Just to let you know, No I didn't ever get a solution that worked for this and at the time the client dropped the requirement so I forgot all about it. Really it needs some PR's to core so would need discussions with HQ to really consider how best to handle it IMO :-)
Thanks
Nik
Had the same request from a client, would be great to see this feature implemented.
I've suggested it as a feature here: https://github.com/umbraco/Umbraco-CMS/discussions/10492
Hi!
We tend to use HtmlAgilityPack for stuff like this to clean/parse and process stuff.
Something like:
is working on a reply...