问题
While creating GitHub Pages for my project I was suggested to import existing README.md
as the project's homepage. Later, I merged gh-pages
with master
and ended up with both index.html
and README.md
.
The "problem" is that the updates to README.md
won't affect index.html
. Is there any simple way to keep them in sync? Preferably with zero Jekyll knowledge...
回答1:
Here's what I came up with, in case someone is interested.
Typically I write HTML using Jade preprocessor, and luckily it does support GitHub Flavored Markdown which is the language README.md
is written in. So my steps where as following:
- Translate
index.html
generated by GH Pages to Jade. I used online html2jade tool; - Save the output to
index.jade
; Locate
section
block in the resulting markup inindex.jade
and replace its entire content with:section include:md README.md
- Run
jade index.jade
which produces new, automatically generatedindex.html
; - Commit both files to
gh-pages
.
See example in this commit on GitHub.
来源:https://stackoverflow.com/questions/22449520/keeping-gh-homepage-in-sync-with-readme-md