好多盆友对本站是如何搭建起来的感兴趣。今天就来自我解剖一下,说说这个站点是如何搭建起来的。
先回顾一下历史吧。其实这个博客最早是跑在GoDadday的WordPress主机上的,正如想象的那样,WordPress让一切都变得那么“简单”,在线更新,评论管理等等,都一手包办了……以至于我都觉得“简单”的没有挑战性。同时,随着GoDadday托管费用像抢钱一样越涨越高,我深深感觉这里的坑太深,迫切需要换一种方式折腾一下。
整体构架
于是乎,趁着Node.js的东风,我找到了Hexo,一个基于Node.js的静态博客引擎。Hexo的工作方式很简单,就是将写好的Markdown格式的文本转换成静态的HTML文件。同时Hexo提供了一个基于Node.js的Web服务器,让你可以在本地运行静态博客。
当然,只能在本地运行是没有多少实际意义的,hexo最NB的地方就是和Github集成,将生成的静态资源打包部署到Github仓库上。这样,通过 http://xxx.github.io
的方式,就可以将静态博客托管到Github上了。
如果你不知道我在讲什么的话,就看看下面这个示意图吧。
基本配置
可以在[blog_folder]/_config.yml
中进行配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| title: 夕阳下的奔跑 subtitle: 不积跬步 无以至千里 description: 个人总结, 工作日志, 技术原创 author: K.X language: zh-CN timezone: Asia/Shanghai url: http://xintq.net root: / permalink: :year/:month/:day/:title/ permalink_defaults: source_dir: source public_dir: public tag_dir: tags archive_dir: archives category_dir: categories code_dir: downloads/code i18n_dir: :lang skip_render: new_post_name: :year-:month-:day-:title.md default_layout: post titlecase: true external_link: true filename_case: 1 render_drafts: false post_asset_folder: false relative_link: false future: true highlight: enable: true line_number: true auto_detect: false tab_replace: default_category: uncategorized category_map: tag_map: date_format: YYYY-MM-DD time_format: HH:mm:ss per_page: 10 pagination_dir: page theme: jacman Plugins: - hexo-generator-feed - hexo-generator-sitemap - hexo-footnotes port: 40000 server_ip: 0.0.0.0 logger: false logger_format: markdown: gfm: true pedantic: false sanitize: false tables: true breaks: true smartLists: false smartpants: true sitemap: path: sitemap.xml feed: type: atom path: atom.xml limit: 50 rss: /atom.xml toc: maxDepth: 2 class: toc deploy: type: git repo: https://github.com/xintq/xintq.github.com.git branch: master
|
主题
Hexo提供了很多漂亮的主题,本站是基于jacman这个主题的。jacman是一款扁平化,有着响应式设计的 Hexo 主题。通过修改配置文件[blog_folder]/themes/jacman/_config.yml
可以进行自定义。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
| menu: Home: / Archives: /archives About: /about widgets: - category - tagcloud - links - rss rss: /atom.xml imglogo: enable: true src: img/logo.png favicon: img/favicon.ico apple_icon: img/jacman.jpg author_img: img/author.jpg banner_img: img/banner.jpg theme_color: theme: '#7f7f7f' index: expand: false excerpt_link: Read More close_aside: false mathjax: false creative_commons: none author: intro_line1: "Hi there, I'm K.X, a tech guy trying to survive in the IT jungle..." intro_line2: "This is my blog. Hope you find something useful here." weibo: weibo_verifier: tsina: douban: zhihu: email: "test@abc.com" twitter: github: "test" facebook: linkedin: "test" google_plus: stackoverflow: toc: article: true aside: true links: LinkedIn: https://cn.linkedin.com/in/xintq 开源中国: http://my.oschina.net/xintq/blog duoshuo_shortname: disqus_shortname: jiathis: enable: false id: tsina: google_analytics: enable: false id: site: baidu_tongji: enable: false sitecode: cnzz_tongji: enable: false siteid: ShowCustomFont: true fancybox: true totop: true google_cse: enable: false cx: baidu_search: enable: false id: site: http://zhannei.baidu.com/cse/search tinysou_search: enable: false id: swift_search: enable: true
|
评论管理
可以参考本站的 《用Gitment替换多说来为基于hexo的静态网站提供评论功能》 进行配置。
搜索
本站使用的是swiftype进行站内搜索的,具体配置方法请参考 这篇 教程。
日常操作
- 创建新文章:
hexo new "My Post Title"
- 更新静态资源(将有改动的markdown文件转换成html):
hexo g
- 运行本地站点:
hexo s
- 部署到Github上:
hexo d
, 这一步需要Git配合,而且在Windows环境下,最好在Git Bash中执行。
上面的2
和3
可以使用hexo s -g
来同时进行。
同样,上面的2
和4
可以使用hexo d -g
来同时进行。
== THE END ==