HACKER Q&A
📣 tomcam

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 Accepted Answer ✓
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?