What is the easier way to embed a GitHub README.md file into a remote website?
I would love to have a synchronized copy of the README file on a web page, I think GitHub pages don't allow users to do so, and I didn't find my answer in the GitHub API. Any idea?
Depends on what kind of a copy you want if you want a file copy like in example.com/project/README.md or something displayed on a php page. If what you want is the first you can make a php script to fetch the file to your server. But if you want to have it on a php page you can use something like :
<?php
$url = "https://raw.github.com/USER/PROJECT/README.md";
$readme = file_get_contents($url);
print $readme;
?>
And this would be the fetch script I mentioned earlier
<?php
$url = "https://raw.github.com/USER/PROJECT/README.md";
$readme = file_get_contents($url);
$file = fopen('README.md','w');
fputs("$file","$readme");
fclose($file);
?>
This can be a solution to my problem: Using the GitHub API and PHP to Get Repository Information, and here is a working demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With