美文网首页程序员
使用Hexo 搭建博客

使用Hexo 搭建博客

作者: 九旬大爷的梦 | 来源:发表于2017-12-03 00:06 被阅读6次

参考1
参考2
参考3

$ hexo server  =>  $ hexo s
$ hexo deploy  =>  $ hexo d
$ hexo generate  =>  $ hexo g
$ hexo deploy -generate  =>  $ hexo d -g
image.png
image.png
image.png

上传到网上

  • hexo generate
  • hexo deploy
    输入账户密码
张宁乐

next主题配置

  1. 进行推送

推送一般分三步
hexo clean
hexo generate (或者hexo g)
hexo deploy (或者hexo d)

本地测试
hexo clean
hexo s --debug
二、写文章
在blog目录下执行创建文章指令

1 $ hexo new "blog1"
2 INFO Created: ~/blog/source/_posts/blog1.md

然后修改source/_posts/blog1.md文件:

$ vim source/_posts/blog1.md
1 ---
2 title: blog1
3 date: 2016-08-25 18:50:03
4 tags:
5 ---
6
7 我的第一篇文章!
清理后启动,就可以看到博客中新增加的文章了。
$ hexo clean
$ hexo s --debug
next 主题配置文件

├── .github            #git信息
├── languages          #多语言
|   ├── default.yml    #默认语言
|   └── zh-Hans.yml      #简体中文
|   └── zh-tw.yml      #繁体中文
├── layout             #布局,根目录下的*.ejs文件是对主页,分页,存档等的控制
|   ├── _custom        #可以自己修改的模板,覆盖原有模板
|   |   ├── _header.swig    #头部样式
|   |   ├── _sidebar.swig   #侧边栏样式
|   ├── _macro        #可以自己修改的模板,覆盖原有模板
|   |   ├── post.swig    #文章模板
|   |   ├── reward.swig    #打赏模板
|   |   ├── sidebar.swig   #侧边栏模板
|   ├── _partial       #局部的布局
|   |   ├── head       #头部模板
|   |   ├── search     #搜索模板
|   |   ├── share      #分享模板
|   ├── _script        #局部的布局
|   ├── _third-party   #第三方模板
|   ├── _layout.swig   #主页面模板
|   ├── index.swig     #主页面模板
|   ├── page           #页面模板
|   └── tag.swig       #tag模板
├── scripts            #script源码
|   ├── tags           #tags的script源码
|   ├── marge.js       #页面模板
├── source             #源码
|   ├── css            #css源码
|   |   ├── _common    #*.styl基础css
|   |   ├── _custom    #*.styl局部css
|   |   └── _mixins    #mixins的css
|   ├── fonts          #字体
|   ├── images         #图片
|   ├── uploads        #添加的文件
|   └── js             #javascript源代码
├── _config.yml        #主题配置文件
└── README.md          #用GitHub的都知道

第二步和第三步可以精简为hexo d -g或者hexo g -d。
这时候,在浏览器输入*.github.io,应该能看到之前你在本地测试的时候看到的网页了。
hexo 写作注意
新建文章,新建标签
多说评论

创建新页面
hexo new page about

个人网站地址:http://cherryblog.site/,顺便求个fork

附录1:站点配置文件

 # Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site   站点信息
title: Cherry's Blog    #站点名字
subtitle: To Be a Batter Me  #副标题
description: 做更好的自己   #站点描述,在侧边栏显示
author: Cherry   #博主名字
email: 991939332@qq.com #联系邮箱
language: zh-Hans   #使用的语言包,语言包在主题文件的language文件夹下,可以更改网站显示出的文案
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
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: true  #新建一个页面后自动生成一个同名文件夹(默认为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: next

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: https://github.com/sunshine940326/sunshine940326.github.io.git
  #repository: ssh://git@github.com/sunshine940326/sunshine940326.github.io

测试是否成功运行

hexo clean清理一下目录,
hexo g重新生成一次所有的文档,
hexo s运行服务器以后,就可以查看评论效果了,效果可以预览我的博客
hexo d
上传

经典的next主题
hexo主题大全
主题1
主题2
主题3
主题4
hexo 爬坑文章
免费域名

相关文章

网友评论

    本文标题:使用Hexo 搭建博客

    本文链接:https://www.haomeiwen.com/subject/wfynbxtx.html