Octopress博客技巧
0.首页仅显示部分
只需要在 post 的 markdown 文档里面适当位置加上 <!--more-->
即可。这样就不会在首页显示此代码以后的部分。另外,还会在首页的相同位置添加一个 read on 的链接,点击即可阅读全文。
1.插入图片
参考 Image Tag
<img class="right" src="http://ginsmile.github.io/images/pic/octopress_logo.png" width="227" height="227" title="octopress_logo" alt="octopress_logo"> |
2.草稿
只需要在新的 post 的头步加入 published: false
即可。
比如本文头部为:
--- |
需要注意的是,在使用 preview 查看的时候,草稿还是会显示的,但是在 deploy 的时候,草稿并不会在 _deploy 中生成,也就是说不会在 username.github.io 上显示。
3.添加类别
单个类别:
categories: octopress |
多个类别:
#方式一 |
4.rake Deploy 失败的解决办法
rake deploy 失败通常是因为不小心在 GitHub 修改了 master 分支,错误信息大概如下:
## Pushing generated _deploy website |
这时候,需要修改 RakeFile 文件(Octopress 目录下)来强制推送,这里参考了 stackoverflow的解决办法
第 264 行:
system "git push origin #{deploy_branch}" |
修改为:
system "git push origin +#{deploy_branch}" |
注意:此方法使强制推送,会删除 GitHub 上的所有的本地分支没有的提交。记住推送完毕后再把 RakeFile 文件改回来。
5.更换网页 Favcion
这个只需要拿一个新的 16×16 的 favicon.png 的图片来替换 source/favicon.png 即可。然后 `rake generate
,
rake preview` 就会在 localhost:4000 端口看到结果。不过有时会由于缓存的原因不能马上看到结果。
6.rake Preview 命令执行后的 TCPServer Error: Address already in use
错误
这种情况,是因为端口已经被使用了,就需要找到占用端口的进程,然后杀掉!
$ lsof -wni tcp:4000 |
PID 指的是杀掉的进程的 ID,可以从第一个命令中获得。
7.错误 WARN Could not Determine Content-length of Response Body 的解决
这是一 Webrick 引发的问题,详细错误如下:
WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true |
可以用以下方法来解决,在 Octopress/Gemfile
中,添加以下命令:
gem 'thin' |
8.bundle Install 不成功
升级 Mac OS 到新版本后,出现的一系列错误。
- 首先运行 rake 命令会出现
Could not find RedCloth-4.2.9 in any of the sources
错误。 - 根据提示运行
bundle install
后,出现ERROR: Failed to build gem native extension.
错误。 - 根据提示运行
Make sure that
gem install RedCloth -v ‘4.2.9’succeeds before bundling.
后,又出现安装错误,提示安装本地扩展失败。
其原因是升级新 mac 系统后未 rebuilt 之前安装的 ruby,所以需要以下步骤来 rebuilt
rvm --force install 1.9.2 |
参考资料
stackoverflow/warn-could-not-determine-content-length-of-response-body-set-content-length-of
stackoverflow/failed-to-build-gem-native-extension-when-install-redcloth-4-2-9-install-linux
The Why·Liam·Blog by WhyLiam is licensed under a Creative Commons BY-NC-ND 4.0 International License.
由WhyLiam创作并维护的Why·Liam·Blog采用创作共用保留署名-非商业-禁止演绎4.0国际许可证。
本文首发于Why·Liam·Blog (https://blog.naaln.com),版权所有,侵权必究。
本文永久链接:https://blog.naaln.com/2013/10/octopress-blog-tips/