Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destination of render-link can't be validated if destination is inside a param #7010

Closed
karamme opened this issue Mar 3, 2020 · 5 comments
Closed
Labels

Comments

@karamme
Copy link

karamme commented Mar 3, 2020

When we have this markdown file:

+++
title = "test"
mylink = "https://www.example.com"
+++

This is an external [link](https://www.example.com)

Another external [link]({{< param "mylink" >}})

and this render-link.html:

{{ .Text }} -> {{ .Destination }} -> {{ strings.HasPrefix .Destination "http" }}

The output will be this:

This is an external link -> https://www.example.com -> true

Another external link -> https://www.example.com -> false

My expectations are that the second link should validate to ´true´ as well. I tried ´print´ to parse the variable, but I could not get the second case to work. Maybe this behaviour can be fixed in an upcoming release. Thanks.

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.66/extended windows/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

yes

@marcellmars
Copy link

I don't know if what would you like to see in Hugo will eventually end up there but here is another way how you could do that...

If you make your own shortcode for example layouts/shortcodes/prms.html and inside prms.html you have:

{{ printf "[%s](%s)" (.Get 0) ($.Page.Param (.Get 1)) | $.Page.RenderString }}

this should do the job:

+++
title = "test"
mylink = "https://www.example.com"
+++

This is an external [link](https://www.example.com)

Another external {{< prms "link" "mylink" >}}

@stale
Copy link

stale bot commented Jul 30, 2020

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Jul 30, 2020
@jmooring
Copy link
Member

jmooring commented Jul 31, 2020

Instead of:

Another external [link]({{< param "mylink" >}})

Do this:

Another external [link]({{% param "mylink" %}})

Duplicate of #7416. Please close.

@stale stale bot removed Stale labels Jul 31, 2020
@karamme
Copy link
Author

karamme commented Aug 2, 2020

Thanks for the input. Rendering the param does indeed help, so I will close this issue and keep track of the other one.

@karamme karamme closed this as completed Aug 2, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants