(迁移自旧博客2017-04-10)html
不少人想要一个本身的博客,无论是写文章仍是技术分享,hexo都是不错的选择。hexo是一款基于Node.js的静态博客框架,可能第一次搭建起来会有不少坑,不过仍是很简单的。下面是搭建步骤。
前端
Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。安装后能够把本地的hexo内容提交到github上去。
node
没有账号的能够注册,已经有的请自动略过。须要注意的是用户名必定要起本身喜欢的,由于后期用用户名做域名。git
对于前端开发者来讲,以上三者是开发必备,还不会的能够去网上看看教程。
git教程推荐廖雪峰的博客。
github
$ sudo npm install hexo-cli -g
下面就能够生成博客,上传到github上了。
执行init命令初始化hexo,命令:web
hexo init
生成静态页面npm
hexo generate(hexo g也能够)
本地启动浏览器
启动本地服务,进行文章预览调试,命令:bash
hexo server (hexo s 也能够)
浏览器输入http://localhost:4000服务器
若是能跑起来就基本没问题。固然你的博客刚打开不会这么炫酷,个人是后期配置好的,想要博客更好看就从第一步慢慢作起吧。
接下来让博客跑在guthub服务器上。
创建Repository
创建与你用户名对应的仓库,仓库名必须为【your_user_name.github.io】,固定写法。
接下来写好文章就能发布到 Github 上了,第一次发布须要安装hexo-deployer-git自动部署发布工具。
$ npm install hexo-deployer-git --save
接下来提交博客,博客网址即为 username.github.io
$ hexo d -g
之后每次写完文章都是这么提交。
下载个好看的主题:(固然能够本身搜好多其余主题)
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
咱们对博客修改相应的配置,咱们用到_config.yml文件,下面是该文件的默认参数信息:
# Hexo Configuration ## Docs: https://hexo.io/docs/configuration.html ## Source: https://github.com/hexojs/hexo/ # Site title: # The title of your website subtitle: # The subtitle of your website description: # The description of your website author: # Your name language: # The language of your website timezone: # URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url: http://yoursite.com/child root: / permalink: :year/:month/:day/:title/ permalink_defaults: # Directory source_dir: source public_dir: public tag_dir: tags archive_dir: archives category_dir: categories code_dir: downloads/code i18n_dir: :lang skip_render: # Writing new_post_name: :title.md # File name of new posts default_layout: post titlecase: false # Transform title into titlecase external_link: true # Open external links in new tab filename_case: 0 render_drafts: false post_asset_folder: false relative_link: false future: true highlight: enable: true line_number: true auto_detect: false tab_replace: # Category & Tag default_category: uncategorized category_map: tag_map: # 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: YYYY-MM-DD time_format: HH:mm:ss # Pagination ## Set per_page to 0 to disable pagination per_page: 10 pagination_dir: page # Extensions ## Plugins: https://hexo.io/plugins/ ## Themes: https://hexo.io/themes/ theme: landscape # Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type:
不要被吓到,须要配置的只有几项,英文好的同窗轻松搞定。
修改网站信息:
title: 个人博客 subtitle: the stack of it nerds description: 描述 author: 你的名字 language: zh-CN timezone: Asia/Shanghai
配置部署:
(必定要修改)
theme: next deploy: type: git repo: https://github.com/iyanming/iyanming.github.io.git
想要美化的朋友能够到Next主题官网查看教程,在主题配置文件下改参数。
终于到了激动人心的时候了!!!
在 /source/_posts 下建立你的第一篇博客吧。
文章是后缀为md的文件,用markdown书写博客,推荐在线编辑网站小书匠,可导出到本地,而后执行hexo d -g提交博客。
而后大家可能不想用github上username.github.io这个域名,那接下来到腾讯云申请个域名和服务器,学生有优惠一块钱一个月,仍是很实惠的。
域名能够起本身喜欢的名字,固然是没有被占用的状况下。
抢到了以后就要开始域名的绑定了:
首先对域名进行解析
而后在source文件夹里建立CNAME文件,不带任何后缀,里面添加你的域名信息,如:iyanming.cn(注意前面不添加http://) 而后hexo d -g上传到github。这样,其余人就能够经过访问你的域名地址进入你的博客了。 这样,博客搭建基本完成。 固然在搭建过程当中可能会有bug或者会在某一步卡住,多思考,多百度,其实仍是很容易的。