Hexo结合Github创建静态博客
2016-08-05 15:48
621 查看
环境部署
安装node.js,地址为:http://nodejs.org/download/安装git,地址为:http://git-scm.com/download/
安装hexo,cmd中运行
$ npm install -g hexo
github上申请账号,并且创建仓库,仓库的名字必须为:你的账户名.github.io
创建hexo项目
首先初始化文件目录
$ hexo init
安装所需文件
$ npm install
运行文件
$ hexo server浏览器输入localhost:4000,你就可以在本地查看到新建的项目。
创建新的文章
$ hexo new "文章题目"进入路径 项目\source_posts\中手动编译文章页面,使用markdown模式。
部署到github上
在配置文件中(项目_config.yml)修改数据# Deployment ## Docs: http://hexo.io/docs/deployment.html deploy: type: github repository: git@github.com:你的账户名/你的账户名.github.io.git branch: master
或者
# Deployment ## Docs: http://hexo.io/docs/deployment.html deploy: type: git repository: https://github.com/你的账户名/你的账户名.github.com.git branch: master
然后执行命令
hexo clean清除旧的内容
hexo g或者
hexo generate生成新的内容
hexo d或者
hexo deploy部署上传
查看成果
等一分钟,你就可以通过http://你的账户名.github.io/来访问你新创建的静态博客了。
配置文件介绍
# Hexo Configuration ## Docs: http://zespia.tw/hexo/docs/configure.html ## Source: https://github.com/tommy351/hexo/ # Site 这里的配置,哪项配置反映在哪里,可以参考我的博客 title: Zippera's blog #站点名,站点左上角 subtitle: Walk steps step by step #副标题,站点左上角 description: Walk steps step by step #给搜索引擎看的,对站点的描述,可以自定义 author: zippera #在站点左下角可以看到 email: #你的联系邮箱 language: zh-CN #中文显示 # URL #这项暂不配置,绑定域名后,欲创建sitemap.xml需要配置该项 ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url: http://zipperary.com root: / permalink: :year/:month/:day/:title/ tag_dir: tags archive_dir: archives category_dir: categories # Writing 文章布局、写作格式的定义,不修改 new_post_name: :title.md # File name of new posts default_layout: post auto_spacing: false # Add spaces between asian characters and western characters titlecase: false # Transform title into titlecase max_open_file: 100 filename_case: 0 highlight: enable: true backtick_code_block: true line_number: true tab_replace: # Category & Tag default_category: uncategorized category_map: tag_map: # Archives 默认值为2,这里都修改为1,相应页面就只会列出标题,而非全文 ## 2: Enable pagination ## 1: Disable pagination ## 0: Fully Disable archive: 1 category: 1 tag: 1 # Server 不修改 ## Hexo uses Connect as a server ## You can customize the logger format as defined in ## http://www.senchalabs.org/connect/logger.html port: 4000 logger: false logger_format: # Date / Time format 日期格式,不修改 ## Hexo uses Moment.js to parse and display date ## You can customize the date format as defined in ## http://momentjs.com/docs/#/displaying/format/ date_format: MMM D YYYY time_format: H:mm:ss # Pagination 每页显示文章数 ## Set per_page to 0 to disable pagination per_page: 10 pagination_dir: page # 多说评论插件 duoshuo_shortname: #主题 ## Plugins: http://hexo.io/plugins/ ## Themes: http://hexo.io/themes/ theme: light exclude_generator: plugins: - hexo-generator-feed - hexo-generator-sitemap # Deployment 站点部署到github要配置,上一节中已经讲过 ## Docs: http://zespia.tw/hexo/docs/deploy.html deploy: type: github repository: https://github.com/你的用户名/你的用户名.github.io.git branch: master
更换主题
hexo有很多的主题,你可以去网上下载,而且都有各种教程,每个主题都有自己的说明文档,能够更好的定制化你自己的博客网站,我所使用的是next主题。具体可以进入 http://theme-next.iissnan.com/ 页面查看。
备份
假如你想要在不同的电脑上写博客,除了都要安装环境外,你可以把项目提交到github上的另外一个仓库,或者该仓库的另外一个分支,每次换电脑都同步一下,非常的方便简单。
相关文章推荐
- Github Pages和Hexo创建静态博客网站
- Github Pages和Hexo创建静态博客网站
- Hexo结合Github-Pages搭建静态博客
- 使用hexo和Github上创建自己的博客
- 使用Hexo搭建Github个人静态博客
- GitHub+Hexo搭建个人静态博客
- github创建可访问的静态网站,个人博客教程
- 利用github webhook 结合openresty自动更新静态博客
- Hexo搭建Github Pages托管的静态个人博客
- Hexo + Github Pages静态博客搭建简明教程
- 利用hexo和github搭建静态博客(一)
- 用GithubPages创建静态博客
- 使用github和hexo搭建静态博客
- 使用hexo创建github博客
- Github Pages+Hexo搭建静态博客
- Hexo搭建Github Pages托管的静态个人博客
- 使用github和hexo搭建静态博客
- Hexo+Next搭建Github个人静态博客
- Hexo搭建Github静态博客(windows)
- 整理下github+hexo静态博客的配置过程