Hexo 建站过程

时间:2022-07-22
本文章向大家介绍Hexo 建站过程,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Hexo官网地址 常用指令 hexo clean && hexo g && hexo d (线上部署) hexo s -p 8088 (本地部署)

什么是 Hexo?

Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。

安装前提

安装 Hexo 相当简单。在安装前,您必须检查电脑中是否已安装下列应用程序:

Node.js Git

如果您的电脑中已经安装上述必备程序,那么恭喜您!接下来只需要使用 npm 即可完成 Hexo 的安装。

首先,在某个文件夹下,使用 Shift + 右键,选择在此处打开Powershell窗口

安装 hexo 命令

npm install -g hexo-cli

到此,hexo 已经安装完毕,可以使用其命令 hexo xxx

安装 Hexo

指定blog目录(自定义路径): C:UsersRayDesktopHexoblog

在blog目录下,右击,选择 Git Bash Here

输入指令

hexo init

回车,等待

至此,建站完成,可以输入以下指令,打开本地hexo

hexo s -p 8088

在浏览器访问:http://localhost:8088/

开始建站

Gitee创建项目

点击头像左边的 + 号,新建仓库,输入仓库名称(仓库名称最好跟Gitee账号保持一致)

得到HTTPS 或 SSH

修改 blog 配置

打开路径 C:UsersRayDesktopHexoblog 下的 _config.yml 文件修改

第一处 Site

# Site
title: Hexo
subtitle: ''
description: ''
keywords:
author: John Doe
language: en
timezone: ''

示例

# Site,这一块区域主要是设置博客的主要说明,需要注意的是:每个冒号后面都是有一个空格,然后再书写自己的内容的
title: 有天你会让我妒忌的
subtitle: hello 2020, bye 2017.
description: 「Just do it」
author: Remember_Ray
email: 343509740@qq.com
language: zh-Hans
timezone:

第二处 URL

# 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:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

示例(仓库名称和Gitee账号一致)

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://gitee.com/您的Gitee名称
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing index.html from permalinks

示例(仓库名称和Gitee账号不一致)

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://gitee.com/您的Gitee名称
root: /仓库名称/
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing index.html from permalinks

第三处 Deployment

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: ''

示例

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://gitee.com/您的Gitee名称/您的仓库.git
  branch: master

Git 操作

打开路径 C:UsersRayDesktopHexoblog ,也就是blog根目录,输入命令

hexo clean && hexo g && hexo d

之后会弹出一个对话框,输入您的gitee账号密码,完成上传

ERROR Deployer not found: git

注意:如果出现了这种问题 ERROR

ERROR Deployer not found: git

使用 Shift + 右键,选择在此处打开Powershell窗口,输入指令安装即可

npm install --save hexo-deployer-git

重新输入命令即可

hexo clean && hexo g && hexo d

开启 Pages 服务

默认即可

以后blog提交完后,都要到这里更新一下,页面才会同步刷新

访问 bolg

https://qq343509740.gitee.io