jonathan-reisdorf / kirby-static-site-generator

Static site generator plugin for Kirby 3/4. With this plugin you can create a directory with assets, media and static html files generated from your pages. The result is an even faster site.
MIT License
2 stars 1 forks source link

Added trailing slash generates faulty canonical links #2

Open thusslack opened 3 months ago

thusslack commented 3 months ago

This is more of a question, than an issue.

https://github.com/jonathan-reisdorf/kirby-static-site-generator/blob/54a02f340d5c6c0764608e93ce734298f0c64e26/class.php#L68

This line generates faulty canonical links in our setup. Our static sites runs in a subfolder (e.g. https://domain.tld/static). When generating a static site given this base url, the canonical link of the homepage always has a trailing slash. Thats not totally wrong, but unwanted in our case.

Since kirby already does a great job with generating urls, what is this line needed for?

jonathan-reisdorf commented 2 months ago

Hello :wave: Thanks for reporting! I added this change in 2019 as part of https://github.com/d4l-data4life/kirby3-static-site-generator/pull/2 when fixing static site generation for single-language sites, but I don't exactly recall why I it seemed necessary back then. This should be solvable more elegantly respecting the original settings, but fixing it will require some testing since in _generatePage there's a lot of rewriting going on to match URLs rendered in different ways, especially also since things were primarily tested without protocol and domain in their base url, so e.g. only /static