Github – way to embed github code into an iframe


The question may seem confusing so let me clarify.

Github lets you see the source code of a files in a repo. I want to include them in iframes but am unsure how and suspect someone has already done this before.

In my case I want to add to an iframe so that from my website people can see the code as it evolves.

Best Solution

A GitHub page itself wouldn't be put directly in a iframe (because of the X-Frame-Options: deny HTTP header).

That leaves you with the GitHub API for contents

GET /repos/:owner/:repo/contents/:path


You should be able to put that content in a iframe (as in this answer)