I would like to make my WordPress blog installed on Localhost to push into GitHub and run that on GitHub as a static page. Can I do it, and if yes please give me a detailed answer with the steps and problems involved?
I don't care if my page is static, but will I be able to host it on GitHub pages?
6 Answers
This website gives a good answer on how to do this:
In short:
- Set-up GitHub pages.
- Install Simply static plugin into WordPress.
- Push the export from the plug-in back to your git repository and you are done!
You can't. You would use WordPress if you want a dynamic page - that is the whole point of using it. You could of course grab the html generated by WordPress and push that to your GitHub, but that I think that would be a lot of manual work.
You could try a static page generator, i.e.
2If you absolutely can't switch from wordpress, but absolutely need to host on github pages, then your only option is probably to look into some wordpress plugin that will take your entire site and spit out a static website (sort of like jekyll, but for wordpress specifically).
edit: There actually is such a plugin:
I just tested it out on a brand new WP installation and it seems to work alright, but a few things seem not to work.
0Unfortunately, and simply you can't do this as WordPress is a WebApp, that is, requires a database. Sorry to be the bringer of bad news.
If you are considering an alternative, consider the following static site generators which can be hosted from GitHub Pages:
0You can migrate fromwordpress to jekyll static site generator, the one powering github pages.
You will find migration documentation on the jekyll site.
No, for that you would need:
- static site generator (like Hugo)
- following a process similar to Andy's "Simple Workflow Deploy to Github Pages using Git".
It might not address your wordpress aspect of the question, but can help other wanting to publish static pages on GitHub.
(And yes, you can migrate from wordpress to Hugo, plus there is an pending request)
0
- Go to Github, create a new repository with this convention:
.github.io.
For clarity sake, my repo would beandy4thehuynh.github.io.- Also, create a local instance of a hugo repo.
Cd into an empty directory on your local machine and executehugo new site ./.
Initialize a git repo withgit initand add your remotegit remote add origin :<your_handle>/<your_handle>.github.io.git.
Cool, we have a fresh blog repo.- Let’s add a test post; execute
hugo new post/test.mdandecho 'Your live on Github Pages' >> ./content/post/test.md.
Set the draft flag to true to make sure your post renders.- Tell Hugo to build your site by running
hugo.
Your public directory should be populated with a freshly generated site. Awesome!- Here comes the sauce; perform a
echo 'public' >> .gitignore. Now, Git will have no idea of your public directory (your compiled public content users will view in a browser). You’ll see why quickly.- Switch out of the
masterbranch withgit checkout -b source. We do this since GH pages doesn’t care about our source code (aka our source branch). It only cares about the public content.- Add and commit your source changes. Do a
git add -Aandgit commit -m 'Initial Commit'. Push your changes withgit push origin source.- Lastly, cd into your
publicfolder. Notice Git is not keeping track of changes here. This was for intended purposes. Do agit init,git add -Aandgit commit -m 'Initial commit'. Push your changes withgit push origin master.Open a browser to your repo named
.github.ioand switch between yoursourceandmasterbranches.
All your compiled content should be in yourmasterbranch.
GH pages will see that and render it at<your_handle>.github.io.
You’ll write your drafts in yoursourcebranch. Compile it with thehugocommand. When your happy with your compiled changes, push yourpublicfolder and become a rock star.