From 54744ba6943321c22e69d65ef2377b398f70eb7d Mon Sep 17 00:00:00 2001 From: Syphdias Date: Sun, 28 Mar 2021 16:09:22 +0200 Subject: [PATCH] Fix path in editPost URL for Windows (#333) `.File.Path` is OS dependant and uses `\` as directory separator. This leads to cases where posts get the wrong URL, if in a sub folder, e.g. `content/posts/folder\post.md`. One idea was to replace `\` with `/` this however breaks valid files (on Unix systems) which include `\` in the file name. According to the docs [`path.Join`](layouts/partials/edit_post.html) is OS unaware and converts to a Unix-like path. > Note: All path elements on Windows are converted to slash ('/') separators. PS: It looks like hugo also uses this internally to build URLs. PPS: Solution was discussed in #278. --- layouts/partials/edit_post.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layouts/partials/edit_post.html b/layouts/partials/edit_post.html index 21a33eb5..d905b32a 100644 --- a/layouts/partials/edit_post.html +++ b/layouts/partials/edit_post.html @@ -1,6 +1,7 @@ {{- if or .Params.editPost.URL .Site.Params.editPost.URL -}} +{{- $fileUrlPath := path.Join .File.Path }} {{- if or .Params.author $.Site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }}| {{- end -}} - + {{- .Params.editPost.Text | default (.Site.Params.editPost.Text | default (i18n "edit_post" | default "Edit") ) -}} {{- end }}