euccas.github.io

why a developer writes

Octopress Tips

| Comments

使用Octopress搭建这个blog已经有一段时间了,记录几个使用中需要注意的Tips.

Tip 1: Clone Repo

如果需要重新复制一份已经存在的blog repo,在重新复制的blog repo上继续发布更新blog,那么需要注意:

首先需要复制的repo是source branch.

如果repo的默认branch已经设定为source branch:

1
git clone <repo url>

如果repo的默认branch设定为master branch:

1
2
git clone <repo url>
git pull origin source

然后需要把master branch复制到_deploy目录。注意_deploy目录是在Octopress生成post的过程中必须存在的。

1
2
3
git clone <repo url> _deploy
cd _deploy
git pull origin master

Tip 2: Push Changes to Source

使用rake gen_deploy将改动发布到master branch之后,还需要把source的改动也提交到source branch

1
git push origin source

Tip 3: Execute Rake Commands

如果因为rake版本问题造成rake command不能够在repo中执行,就需要使用bundle exec rake执行。

1
2
3
4
bundle exec rake new_post
bundle exec rake generate
bundle exec rake preview
bundle exec rake deploy

Tip 4: Errors in gen_deploy

rake gen_deploy的过程中,如果在generate步骤中出现错误(比如部分post的文本不符合markdown语法),一些情况下可能会造成generate目录中的文件被删除。而gen_deploy过程此时并不会结束,deploy会继续进行,这样最终的commit就会把原来已经发布的blog内容删除。防止出现这种问题的安全做法是分步执行rake generaterake deploy

Comments