[Share Experiences] 搭建hexo博客
Tofloor
poster avatar
青稚°
Moderator
2023-05-10 19:14
Author

这里以npm为例

参考这个安装nodejs,把里面的18.X改成20.x

https://bbs.deepin.org/post/253943

安装好npm别着急

换成淘宝源提高下载速度

npm config set registry https://registry.npmmirror.com

sudo npm config set registry https://registry.npmmirror.com

还原命令

npm config set registry https://registry.npmjs.org/

sudo npm config set registry https://registry.npmjs.org/

测试是否成功

npm config get registry

sudo npm config get registry

好了,咱们开始安装hexo

安装途中如果提示npm更新执行命令

sudo npm install npm@latest -g

hexo安装命令

sudo npm install -g hexo-cli

安装好hexo后开始生成配置目录(不加sudo)

hexo init blog

进入themes目录删除自带主题

之后进入

https://hexo.io/themes/

找到适合自己的主题(本文以为例Vateral)

进入_config.yml将 theme: Vateral(改成你选择的主题)

项目内的本地搜索安装(不加sudo)

npm i -S hexo-generator-search

在主题文件的_config.yml中添加

search:
path: search.xml
field: all

剩下的参考项目

https://github.com/moumao/hexo-theme-Vateral

注意项目没说修改哪个_config.yml

一律修改Vateral目录的_config.yml

而不是blog目录里面_config.yml

搭建仓库github或者gitee,建立和用户名相同的仓库

开启pages

修改blog目录的_config.yml里面的

url:

修改为:url:https://你的用户名.github(或gitee,根据你使用的平台).io

清理

hexo clean

开始生成配置文件(生成前写文章)

hexo g

本地预览

hexo s

之后上传public目录里面的全部文件到仓库

之后进入开启pages页面,更新pages。

开启强制https。

就搭建好博客了

注意每次写一个文章都要执行

hexo clean

hexo g

至于hexo s是本地预览,最好预览下,看看有没有错误。

如何创建文章呢?

hexo new 标题

关于界面创建

hexo new page "about"

开始简单文章写法(坛友可以自己搜索,或者参考下面链接)

https://cloud.tencent.com/developer/beta/article/1662733

以上就是这些,感谢大家支持。

Reply Favorite View the author
All Replies
阿尼樱奈奈
Moderator
2023-05-10 19:17
#1

感谢分享。

Reply View the author
青稚°
Moderator
2023-05-10 19:25
#2
阿尼樱奈奈

感谢分享。

提醒一下,配置好后可以压缩备份,下次直接安npm,hexo就可以了。

还有压缩时候别忘了执行hexo clean

其他主题博客置顶,需要安装插件。

如果遇到主题和hexo不兼容

npm install hexo@4.2.1

安装旧版hexo,后面版本号改成想要的hexo版本

Reply View the author
master
deepin
2023-05-10 19:30
#3

👍

Reply View the author
MMHMM
Moderator
2023-05-10 20:16
#4

kissing_heart

Reply View the author
hanzn-zzx
deepin
2023-05-11 03:52
#5

like

Reply View the author
青稚°
Moderator
2023-05-11 03:56
#6
hanzn-zzx

like

麻烦看下私信。

kissing_heart

Reply View the author
落日
deepin
2023-05-11 23:52
#7

安装nodejs这步我直接用nvm代替了,管理比较方便

Reply View the author
青稚°
Moderator
2023-05-11 23:53
#8
落日

安装nodejs这步我直接用nvm代替了,管理比较方便

嗯,可以的。

Reply View the author
renbooc
deepin
2023-05-12 17:28
#9

感谢分享

Reply View the author
核桃
deepin
2023-05-12 18:15
#10

赞,hexo博客和wordpress那些类似嘛?

Reply View the author
阿尼樱奈奈
Moderator
2024-01-24 10:41
#11

请把文章里面的 https://registry.npm.taobao.org 换成 https://registry.npmmirror.com

原因见:https://zhuanlan.zhihu.com/p/623547625
e8aa96707892bdf5fddc0eae98142b7.png

Reply View the author