
Ask HN: Making a static site generator. How to handle GitHub-style links? - tomcam
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).<p>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&#x27;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&#x27;t exist, generate a link to an .HTML file instead.<p>Mind is a little fuzzy lately so I&#x27;d like feedback on this idea.
======
tiernano
i 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
Thanks 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
not 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
I 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.

