hexo 初始化部署

1.安装Hexo

npm install -g hexo
//npm install hexo-cli -g

复制代码

2.初始化

cd 保存内容的文件夹
hexo init 你的用户名.github.io  // 建议和创建仓库时使用同一个

复制代码

3.Next 安装

  • 安装 Next 主题 切换到上面生成的本地博客目录(xxx.github.io
git clone https://github.com/iissnan/hexo-theme-next themes/next
复制代码
  • 使用 Next 主题 打开本地博客目录下的 _config.yml 文件,搜索,定位 theme 键值,将 theme 的值修改为 next
theme: next //刚刚安装的主题名称
复制代码
  • 站点配置文件基本项修改 关于 Hexo 配置的详细信息请前往Hexo的官方文档

最基础的配置 键值之间一定要 ”加空格“,

 ```
 title: xxx  # 博客的名字,也称站点名称
 author: xxx # 作者名字
description: xxx # 对站点的描述,搜索引擎会抓取,可以自定义(这个还是加上比较好)
language: zh-Hans # 语言 简体中文
theme: next  # 配置主题
deploy: # 部署相关配置
    type: git # 使用 Git 提交
    repo: https://github.com/xxx/xxx.github.io.git # 就是存放博客的仓库地址
 ```
复制代码

站点配置文件详细配置示例

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

 # Site 这里的配置,哪项配置反映在哪里,可以参考我的博客
 title: xxx # 博客的名字,也称站点名称
 subtitle: xxx # 副标题
 description: xxx # 对站点的描述,搜索引擎会抓取,可以自定义
 author: xxx # 作者名字
 language: zh-Hans # 语言 简体中文
 timezone:  # 用默认的即可

 # URL 
 # 这项暂时不需要配置,绑定域名后,要创建 sitemap.xml 时再配置该项
 ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: # http://xxx.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: 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: MMM D YYYY
time_format: H:mm:ss

 # Pagination 
# 每页显示文章数,可以自定义
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

 # Extensions 
 # 配置站点所用主题和插件,这里将默认主题注释,修改为 next
 ## Plugins: https://hexo.io/plugins/
 ## Themes: https://hexo.io/themes/
 theme: next
 #theme: landscape

 # 头像
 # 注意:是 xxx.github.io/source 下的开始的相对路径,如果 source 文件夹下面没有 uploads 文件夹,那么新建一个。考虑到会博客中用很多图片,在 uploads 文件夹下请分好类,避免混乱
avatar: /uploads/images/avatar.jpg

  # Deployment 
  # 本地博客部署到 github 上要配置这里
  ## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git # 使用 Git 提交
  repository: https://github.com/xxx/xxx.github.io.git # 就是存放博客的仓库地址
   
   ```
复制代码

3.生成静态页面

打开命令行,定位到 xxx.github.io 目录
hexo generate

复制代码

4.启动本地server用以验证,浏览器输入http://localhost:4000就可以看到博客的默认效果

hexo server

复制代码

5.将博客部署到Github

hexo deploy

复制代码
- 申请万网域名[万网](https://wanwang.aliyun.com/)
- ping xxx.github.io IP 再配置域名解析IP
- 再本地博客根路径下创建一个文件, 文件名是大写的 "CNAME" 内容是申请的域名
- hexo deploy 部署到github 上,如果不成功,实用git 上传到GitHub仓库内,
- 告一段落,可以使用了
复制代码

转载于:https://juejin.im/post/5b8f7614e51d450e7e51142d

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值