-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add a path.Clean function #8885
Comments
I think that's an even better workaround. Because I want to preserve the original themes pattern more, I will use So another alternative solution beyond changing behavior is to add a note on https://gohugo.io/variables/files similar to the one on the path.Join doc, since I wouldn't know these paths are intended to be converted with something like path.Join (if that is the intention for path.Join) based on the docs for what I was calling. If this issue ends up closed with no action I will at least make a PR on the doc repo. |
There is a longer story here, but the You can work around this today by But I do suggest that we add a
|
@bep Mind if I take a crack at this? |
@bradcypert go ahead. I would expect it to be the output of doing |
Sounds good! Here's a PR: #9005 |
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. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
The issue I'm seeing in windows is that, when using
.File.Path
like so:<a href="{{ $geekdocRepo }}/{{ $geekdocEditPath }}/{{ .File.Path }}">
or rather, in the theme I'm using,<a href="{{ $geekdocRepo }}/{{ $geekdocEditPath }}/{{ $.Scratch.Get "geekdocFilePath" }}">
, the backslashes that would be returned in .File.Path used elsewhere will be replaced with %5c, which will cause broken hyperlinks that were built using .File.Path.I reckon this stems from Windows using backslashes in paths unlike mostly everything else that uses forward slashes (though Windows will accept forward slashes in powershell and explorer). I'm not familiar enough with how URLs to say whether or not the making the HTML parser just not escape backslashes into $5c on URLs, though there's probably plenty of HTML reasons why this gets done.
Without having reviewed the underlying code, I suppose these are possible fixes for this particular breakage (whether they are suitable for other uses, I don't know).
Probably 1 is a better idea, I can kinda noodle some reasons 2 would break things in my head, but I'm not certain.
In the meantime, I can use
<a href="{{ $geekdocRepo }}/{{ $geekdocEditPath }}/{{ replace ($.Scratch.Get "geekdocFilePath") "\\" "/" }}">
in my partial instead, but it seems to me hugo should internally use the same style of slash independent of OS.As an aside, if you don't want people who use the search for existing issues or coming from Google to contribute to those extant issues, lock them when they pass your arbitrary age limit that isn't documented, re:#5515 (comment). Perhaps this could be updated alternatively: https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#reporting-issues.
The text was updated successfully, but these errors were encountered: