grav icon indicating copy to clipboard operation
grav copied to clipboard

If multiple attributes are added to URL link the `rel` attribute is ignored

Open 01Kuzma opened this issue 2 years ago • 3 comments

If multiple attributes are added to URL link the rel attribute is ignored. These two links will be rendered differently: [„Google“ privacy policy](https://policies.google.com/privacy?hl=en?rel=nofollow). the rel=nofollow will be ignored of ?hl=en

[Deny](https://adssettings.google.com/autenced?rel=nofollow) attribute ?rel=nofollow will be rendered

01Kuzma avatar Sep 22 '22 18:09 01Kuzma

Hi @01Kuzma

First of all, you must define the attribute in system.yaml, in pages.markdown.valid_link_attributes, you must add the attribute to use. By default, Grav offers the most used ones (rel, id, classes, target and class). Once you have added the attributes you want to use, the way to put them in the link is as follows:

[Google Privacy Policy](https://policies.google.com/privacy?lang=en&rel=nofollow).

'?' is used to separate the attributes from the rest of the link, but for each attribute you want to use you must use '&'. In your example this is wrong and that is why it does not work for you, but in this case Grav works perfectly. The previous example has the following html output:

<a href="https://policies.google.com/privacy" lang="en" rel="nofollow">Google Privacy Policy</a>

I think that in this case, this issue can be closed.

pmoreno-rodriguez avatar Feb 16 '24 20:02 pmoreno-rodriguez

Hi @pmoreno-rodriguez

'?' is used to separate the attributes from the rest of the link, but for each attribute you want to use you must use '&'. Indeed, it was a typo. Thank you for pointing it out!

01Kuzma avatar Feb 18 '24 14:02 01Kuzma

@pmoreno-rodriguez , but now after recheking I found one issue with this: [Google Fonts](https://developers.google.com/fonts/faq#what_does_using_the_google_fonts_api_mean_for_the_privacy_of_my_users?rel=nofollow)

Is rendered as: <a href="https://developers.google.com/fonts/faq#what_does_using_the_google_fonts_api_mean_for_the_privacy_of_my_users?rel=nofollow">Google Fonts</a> without nofollow param

Any thoughts?

01Kuzma avatar Feb 18 '24 14:02 01Kuzma

I've had a look at the Excerpts.php file, and played around with the processLinkExcerpt function, which I think is responsible for this, but the most I got was returning download="".

pmoreno-rodriguez avatar Feb 22 '24 21:02 pmoreno-rodriguez

@pmoreno-rodriguez , so, it seems it's a bug. It's a pity, that dev's haven't checked it since September 2022!

01Kuzma avatar Feb 23 '24 12:02 01Kuzma

I've had a look at the Excerpts.php file, and played around with the processLinkExcerpt function, which I think is responsible for this, but the most I got was returning download="".

Sorry, I think this answer is for other issue

pmoreno-rodriguez avatar Feb 29 '24 20:02 pmoreno-rodriguez

@pmoreno-rodriguez , but now after recheking I found one issue with this: [Google Fonts](https://developers.google.com/fonts/faq#what_does_using_the_google_fonts_api_mean_for_the_privacy_of_my_users?rel=nofollow)

Is rendered as: <a href="https://developers.google.com/fonts/faq#what_does_using_the_google_fonts_api_mean_for_the_privacy_of_my_users?rel=nofollow">Google Fonts</a> without nofollow param

Any thoughts?

Hi @01Kuzma Finally I've found a solution for this issue. It seems that you have to add the attributes to the url with ? (the first one) and & the others, and after all that, the anchor is set with #, for the part of the page indicated. In the case at hand, your example, this would be the correct way to establish it:

[Google Fonts](https://developers.google.com/fonts/faq?lang=es&rel=nofollow#what_does_using_the_google_fonts_api_mean_for_the_privacy_of_my_users)

I hope I have helped you with this solution.

pmoreno-rodriguez avatar Mar 25 '24 23:03 pmoreno-rodriguez

@pmoreno-rodriguez thank you! This does work!

01Kuzma avatar Mar 27 '24 08:03 01Kuzma