# Best way of linking Github repo code from Github Pages

**URL:** https://talk.jekyllrb.com/t/best-way-of-linking-github-repo-code-from-github-pages/185
**Category:** Help
**Created:** [February 21, 2017, 10:29pm UTC](https://talk.jekyllrb.com/t/best-way-of-linking-github-repo-code-from-github-pages/185 "2017-02-21T22:29:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![daniele.avitabile](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@daniele.avitabile](https://talk.jekyllrb.com/u/daniele.avitabile)
#### Post date: [February 21, 2017, 10:29pm UTC](https://talk.jekyllrb.com/t/best-way-of-linking-github-repo-code-from-github-pages/185/1 "2017-02-21T22:29:25Z")

</div>

Dear All,

I am using Github pages and jekyll to write a scientific tutorial, with code that is also hosted on Github. In my Github repo I have a “codes” folder and a “docs” folder. The former hosts the code, the latter hosts my jekyll website, as recommended on GitHub and Jekyll websites.

In my tutorial I want to discuss/display code that is hosted on the GitHub repo, under “codes”, and I would like to avoid copy/pasting code from the repo to the page. I think it would be much easier to link directly to one of the files in the Github repo.

Is there a way to do this automatically, so that if I change any of the files in “codes”, the changes will be reflected in the Jekyll website?

I know that there exists a Jekyll-gist plugin, but I don’t think I am allowed to use it on GitHub pages. Also I don’t know if this requires me to setup another layer (“a gist”) for each file I want to link to.

Do you know if this can be done at all?

---

<div class="post-metadata">

### Author: ![DavidDarnes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/daviddarnes/32/1349_2.png) [@DavidDarnes](https://talk.jekyllrb.com/u/DavidDarnes)
#### Post date: [February 21, 2017, 10:58pm UTC](https://talk.jekyllrb.com/t/best-way-of-linking-github-repo-code-from-github-pages/185/2 "2017-02-21T22:58:17Z")

</div>

This is an interesting one! Surprised GitHub haven’t offered the option to embed files from repos into sites, I guess the overhead would be quite large. I did a bit of googling and found this which allows you to embed files and chunks of code into pages [http://blog.revathskumar.com/2012/08/embed-files-from-github-repository-into-webpage.html](http://blog.revathskumar.com/2012/08/embed-files-from-github-repository-into-webpage.html)

Hopefully this is good enough to solve your problem ⭐
