Organization github pages and ember
Today we planned to host our website on github-pages as a static website. We decided to used ember
web framework to develop this website. In case of organisation/user github pages, github reads the website source from the master
branch not the gh-pages
branch. This causes an issue: where to keep the ember specific code. As in ember the output code is in dist/
directory. Github needs the code inside the dist
directory to be present in the root directory of the project. So the solution is:
- Create two branches:
ember
: For ember codemaster
: For the final website code.
ember
will be your main branch. Do all the work there.- Then do
ember build --environment=production
. - Copy all the files in the
/dist
folder to the root of yourmaster
branch. - Commit and push.
There is a ember-cli
plugin which can do all these things for you: ember-cli-github-pages. But the readme of this plugin explains everything for Project github pages not for organisation github pages. But after spending some time I finally made it work for the organisation pages. Here are the steps:
- Create new emebr project
ember new myBlog
. HeremyBlog
is the name of the project. -
cd
to myBlog and install ember-cli-github-pages:bash cd myBlog && ember install ember-cli-github-pages
-
Remove the changes made to
environment.js
, as they are not required for Org/User pagesbash git checkout -- config/environment.js
-
Commit the changes:
bash git add -A && git commit -m "Added ember-cli-github-pages addon https://github.com/poetic/ember-cli-github-pages"
- Create new branch named
ember
which will store all the ember related code:git checkout -b ember
-
Run the following command as mentioned above:
bash git checkout master && rm -rf `ls -a | grep -vE '\.gitignore|\.git|node_modules|bower_components|(^[.]{1,2}/?$)'` && git add -A && git commit -m "initialises gh-pages(in case of organisation master) commit"
-
Switch back to ember branch:
bash git checkout ember
-
Build the site using ember-cli-github-pages:
bash ember github-pages:commit --branch master --message "adds base site"
-
Create new Org/User repo on Github and add the origin:
bash git remote add origin https://github.com/knoxxs/knoxxs.github.io.git
Here knoxxs is my username. -
Push the master branch:
git push -u origin master
- Open
http://knoxxs.github.io/
.
I already made a pull request to include these steps in the plugin readme.