3 ms·
Ask HN: Making a static site generator. How to handle GitHub-style links?
Am writing Yet Another Static Site Generator. In Github Pages, internal links must go to .md files, not .html. So for example page1.md links to page2.md like this: [Visit page 2](page2.md).
This seems a little odd to me, so mine expects the actual HMTL link [Visit page 2](page2.html). However, that breaks compatibility with GitHub pages and will probably annoy people. I'm thinking the better behavior would be to for [Visit page 2](page2.md) to look for the .md file at site generation time and if it doesn't exist, generate a link to an .HTML file instead.
Mind is a little fuzzy lately so I'd like feedback on this idea.
- tiernano 6y agoi like the sound of how its done on GitHub alright... if you ever change your URL structure, you dont have to rewrite all your pages to point at the new location, plus if you did, you could write redirects in there too... it would also allow for checking of links; if you link to newpgae.md, not newpage.md, it should throw a "compile" error... what language are you writing this in?
- tomcam 6y agoThanks for the feedback. Don't understand what file extension has with URL structure? It's relative no matter what, or am I missing something? Writing it in Go.
- tiernano 6y agonot necessarily the extension that would link to the url, but the file might be, in my case with Hugo, in posts/2020-01-01-title.md. but when that gets built, it will be in posts/2020/01/01/title.html... you could, in theory, not have the date in the file name, and just use the date from the md file, which then will still generate that way...
- tomcam 6y agoI think that’s due to the way Hugo converts the date portion of the source file, which has a whole bunch of rules about weighting and things, but I’m not smart enough to understand how they work.
- deleted 6y ago[deleted]