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

Return strings from URL functions #11511

Closed
willfaught opened this issue Sep 29, 2023 · 2 comments · Fixed by #11536
Closed

Return strings from URL functions #11511

willfaught opened this issue Sep 29, 2023 · 2 comments · Fixed by #11536

Comments

@willfaught
Copy link

It's surprising that a "URL" is represented by something called template.HTML, even if it's just a string under the hood.

This breaks calling .GetPage with the output of relLangURL.

@jmooring:

ref, relref, relURL, relLangURL, absURL, and absLangURL return template.HTML. The original implementations returned a string. It in unclear when/why the change was made, but it may have happened when the template functions were namespaced.

I've been thinking about this, and can't come up with a good reason for the current data type. We added the urls.JoinPath a few months ago, which returns a string.

See gohugoio/hugoDocs#2000

Alternatively, every function that takes a string could be changed to also take a template.HTML.

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

$ hugo version
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended darwin/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

@jmooring jmooring changed the title relLangURL return type is template.HTML, not string Return strings from URL functions Sep 29, 2023
@jmooring jmooring added Proposal and removed Bug labels Sep 29, 2023
@jmooring
Copy link
Member

jmooring commented Sep 29, 2023

The original implementations returned a string

Correction: the original implementation of absURL returned template.HTML.

Note that .Page.Ref and .Page.RelRef already return strings.

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 Nov 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants