Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Mar 12, 2018 @ 09:58
    Nik
    1

    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

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 12, 2018 @ 11:03
    Lee Kelleher
    1

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

    Hope this helps?

    Cheers,
    - Lee

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Mar 12, 2018 @ 11:49
    Nik
    1

    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.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 12, 2018 @ 12:01
    Lee Kelleher
    0

    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

  • Simon steed 374 posts 686 karma points
    Feb 10, 2020 @ 15:26
    Simon steed
    0

    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

  • Murray Roke 503 posts 966 karma points c-trib
    Mar 24, 2021 @ 02:45
    Murray Roke
    0

    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

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 24, 2021 @ 08:05
    Lee Kelleher
    0

    Just wait until the client's SEO agency ask about the noreferrer and noopener values too. 😁

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Mar 24, 2021 @ 14:22
    Nik
    0

    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

  • Kasper 13 posts 84 karma points
    Jun 17, 2021 @ 13:49
    Kasper
    0

    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

  • Markus Johansson 1909 posts 5733 karma points MVP c-trib
    Sep 06, 2023 @ 07:39
    Markus Johansson
    0

    Hi!

    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;
    
Please Sign in or register to post replies

Write your reply to:

Draft