Skip to content

Fix path in editPost URL for Windows#333

Merged
adityatelange merged 1 commit intoadityatelange:masterfrom
Syphdias:edit-post-link
Mar 28, 2021
Merged

Fix path in editPost URL for Windows#333
adityatelange merged 1 commit intoadityatelange:masterfrom
Syphdias:edit-post-link

Conversation

@Syphdias
Copy link
Copy Markdown
Contributor

.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 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.

`.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 adityatelange#278.
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@adityatelange adityatelange merged commit 54744ba into adityatelange:master Mar 28, 2021
@Syphdias Syphdias deleted the edit-post-link branch March 28, 2021 19:36
mbrukman pushed a commit to mbrukman/hugo-PaperMod that referenced this pull request Apr 4, 2021
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this pull request Feb 21, 2023
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this pull request Feb 21, 2023
`.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 adityatelange#278.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants