How to create personal blog based on hexo

#Install the lasted version of nodejs

cd ~
curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh

If you want to edit it, you can run:

nano /tmp/nodesource_setup.sh

Run the following cmd:

sudo bash /tmp/nodesource_setup.sh

Install the nodejs

sudo apt install nodejs

After finished install, check the version of node and npm

node -v
npm -v
npm fund

#Install Hexo

Run the following cmd:

npm install -g hexo-cli

Create one local folder for you web site

mdkir ~/my_blog

Init the hexo for your web site

hexo init ~/my_blog

Install node_moudles

cd ~/my_blog
npm install 

You will get the follow folder:

node_modules: node依赖包
public: 存放生成的页面
scaffolds: 生成文章的一些模板
source: 存放文章
themes: 主题
_config.yml: 博客的配置文件

Start the hexo server:

hexo clean  #清理静态文件和缓存数据

hexo new "新文章"

hexo g      #生成静态数据(按日期归类的文件夹/html等)

hexo s      #本地启动hexo

Install the deploy plugin:

npm install hexo-deployer-git --save

Modify the config file:

vim _config.yml

deploy:
  type: git
  repo: https://github.com/xxxx/xxx.github.io.git
  branch: master

Commit the blog to git:

git init    #初始化项目文件夹

git add .  #将所有文件添加到暂存区

git commit -m "first commit"   #提交到本地仓库,双引号内是提交的备注信息

git remote add origin https://github.com/chaoyangya/chaoyangya.github.io.git

git pull    #拉取远程主分支信息,首次拉取合并信息

git push -u -f origin master  #提交到远程仓库,这个命令中的 -f 是强制推送,因为远程仓库只有初始化的文件,所以强制推送上去就行了,不加-f 会报当前分支没有远程分支,强制推送可以覆盖master,这样就完成了第一次提交的步骤)

Run deplay cmd:

hexo d -g

Deploy to Netlify

https://app.netlify.com/

#Fix related errors

Error:

Error: listen EADDRINUSE: address already in use :::4000

The default port of hexo server is 4000, maybe you have started one hexo server before that, so check which program uses it.

sudo lsof -i:4000  # 冒号后面填写端口号
kill the pid
sudo kill -9 pid

文章作者: YUV420.COM
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 YUV420.COM !
评论
 上一篇
UML 类图说明 UML 类图说明
UML类图,UML中的一种重要图形,是在面向对象语言用中用来表示一个类。 如下图所示(它由两部分组成,类,类之间的关系): #01 类类是具有相似结构、行为和关系的一组对象的描述符,是面向对象系统中最重要的构造块。 如下图所示,就表示
2023-04-28
下一篇 
HDR和SDR详细图文对比评测 HDR和SDR详细图文对比评测
HDR和SDR详细图文对比评测HDR绝对是一眼可以感官的,但是目前普通照片是无法完全体现出来,感觉HDR各种表现环境的漫反射、光线、和光感,都无法用照片体现。也许屏射HDR是一种误导,但我还是尽可能选择了一些能明显看出的图片。照片顶多体现区
2020-04-22
  目录