google / docsy

A set of Hugo doc templates for launching open source content.
https://docsy.dev
Apache License 2.0
2.62k stars 904 forks source link

Repo page links on right nav broken for Windows builds #2126

Open mbheinen opened 3 days ago

mbheinen commented 3 days ago

Environment

Problem

This issue is described here https://stackoverflow.com/questions/78754682/docsy-edit-link-are-generate-with-local-absolute-path. Basically, the "View page source", "Edit this page", and "Create child page" hyperlinks are broken when doing hugo build on Windows. I think this may have broke with this commit https://github.com/google/docsy/commit/435b2e0678694f3812a285a67dfac43f1c8ddd25 released in Docsy 0.9.0 because it adds a forwardslash to hugo.WorkingDir when creating the trimmed path for the file in the page-meta-links.html template. This was working fine on Hugo v0.115.3 and Docsy v0.7.1 but I noticed it broke when I tried to update to current latest (Hugo v0.138.0 and Docsy v0.11.0)

Easily reproducible by cloning https://github.com/google/docsy-example on Windows and running hugo or hugo serve. You'll notice the hyperlinks for "View page source", "Edit this page", and "Create child page" are paths like

https://github.com/google/docsy-example/edit/main/C:%5csources%5csite%5cdocsy-example%5ccontent%5cen%5cdocs%5c_index.md

Rather than the expected

https://github.com/google/docsy-example/edit/main/_index.md