Search code examples
githubmarkdowndocumentation-generationgithub-pages

How do I prevent the GitHub Pages "Automatic Generator" to remove everything before regenerate the site?


I created a wonderful GitHub Pages website for my little project, and I added some other pages into the gh-pages branch. My problem is that, everytime I regenerate the website from 'Settings=>Automatic Page Generator', everything is cleaned up and I have to restore the files manually.

Is there a way to prevent, or work around this?

It would have been much better if the Automatic Generator was just overwriting his stuff without removing existing files.


Solution

    1. Checkout the gh-pages branch.
    2. mkdir _layouts
    3. move index.html to _layouts
    4. edit _layouts/index.html replace the the inner html of the contents section with {{content}}
    5. make new file index.md
    6. Paste markdown content of automatic page generator into index.md
    7. prepend the following to index.md

      ---
      layout: index
      ---
      
    8. create _config.yml
    9. include the following in _config.yml:

      markdown: kramdown
      kramdown:
         auto_ids: true
      

      this step is to match github's markdown syntax

    10. add & commit changes, and then push branch back to github.

    Now you can simply edit index.md from the gh-branch in your github source browser and it will update using jekyll automatically and not mess with anything in your gh-branch.

    You can also make more items editable in the layout using place holder {{page.varname}} and then adding varname:your text to the header of your index.md.