Search code examples
githubjekyllgithub-pages

How to provide option to preview file before download


I am using github-pages and jekyll to serve my own blog, where sometimes I put script files (python, MATLAB etc...) for the readers to download. Can I provide the readers with an option to preview the code file as text before they download it? I am imagining a scenario like when they click the hyperlink, instead of instantly downloading it, they are shown a page to view the code.


Solution

  • You could host your code snippets as GitHub Gists, then link to the Gists on your blog so that users could view your code and optionally download it as well.