I think the best topic for a first post must be 'how did I build this?', so here we go!
First of all, as I want my blog be served at github pages, I create a new repo name kpacha.github.io. I know the cookbook recomends an easier way, but I don't want the carew installation on my
master branch so, my repo has two branches:
masterbranch stores the last static website builded as it's intended to serve the web contents for github pages
editorbranch stores the carew project and all the markdown pages
So the workflow I'm following here is quite simple:
- checkout the
- create new post
- re-build website
- commit changes
- merge the new website to
- commit changes
- push both branches
Create a new github repo named
<YOUR-GITHUB-USER>.github.io and clone it somewhere in your system
$ git clone https://github.com/<YOUR-GITHUB-USER>/<YOUR-GITHUB-USER>.github.io.git $ cd <YOUR-GITHUB-USER>.github.io
editor branch just typing
$ git checkout -b editor
The best way to start with carew is to use the carew boilerplate: You will need composer.
$ php composer.phar create-project carew/boilerplate . -s dev $ bin/carew build
That's all, you can browse the
Now you must edit the
confi.yml and the
pages/ folder contents.
editor branch has a carew project working, it's time to integrate it in your workflow. It could be done just by adding two more files to the
.gitignore will prevent you from adding the
install will be useful when you want to install your
editor environment after a
#!/bin/bash composer install -o bin/carew build
Remeber to add execution permisions
chmod +x install
Now you can add the root folder into git.
In future checkouts from scratch, you will need to run the
install script before be ready to work!
$ git clone https://github.com/kpacha/kpacha.github.io.git $ git checkout editor $ ./install
$ git checkout master
And add the
.gitignore file from the
$ git checkout editor -- .gitignore
Create a file called
#!/bin/bash git checkout editor -- web cp -rp web/* . rm -rf web git reset HEAD web git status
After adding the execution permissions to
update.sh, add them to git
$ chmod +x update.sh $ git add .gitignore update.sh $ git commit -m "set up the master branch"
Now, every time you want to push your generated statics you must run the
update.sh script, add the untracked files listed, commit them and push the branch to github
editor branch, create your post entry
$ bin/carew generate:post "New post title"
Edit your entry and rebuild your web
$ bin/carew build
Now it's time to commit your changes into your
editor branch and update your
master one. Just type
$ git add . $ git commit -m "adding the 'New post title'" $ git checkout master $ ./update.sh $ git add . $ git commit -m "publishing the 'New post title'" $ git push origin editor $ git push origin master
And you're done!
Put the code for posting in a script for faster publishing. Let's call it
#!/bin/bash git add . git commit -m "adding the '$1'" git checkout master ./update.sh git add . git commit -m "publishing the '$1'" git push origin editor git push origin master
Do not forget to set the execution permisions
$ chmod +x publish
And, after a succesful build, just run
$ ./publish "New post title"