搭建一个hexo博客

安装依赖环境

  • git
  • npm
  • nodejs

安装git

sudo apt install git

安装npm

sudo apt install npm

安装nodejs

sudo apt install nodejs

安装Hexo

npm install -g hexo-cli

hexo的使用

hexo init folder

初始化一个文件夹作为你的blog

hexo new file

在/folder/source/_posts/路径下新建一个file.md文件

hexo s

打开本地预览,在http://localhost:4000预览博客

修改Hexo主题

你可以在Themes|Hexo下载你喜欢的主题,将下载好的主题文件夹移动到/folder/themes/

git clone theme's site

你可以添加about,tags,categories,contact等信息:

hexo new page about
hexo new page tags
hexo new page categories
hexo new page contact

修改/folder/_config.yml完成主题的更换

theme: your theme

/folder/themes/your theme可以选择配置你的主题样式,如果你会CSS,你也可以修改主题的样式模板

部署到github远端

添加你的github信息

git config --global user.name "yourname"
git config --global user.email "youremail"

创建ssh

ssh-keygen -t rsa -C "youremail"

~/.ssh/文件夹中存在id_rsaid_rsa.pub两个文件,其中id_rsa.pub是公钥,把它复制粘贴到github上:

  • setting > SSH and GPG keys > New SSH key — 粘贴

安装deploy-git

npm install hexo-deployer-git --save

修改/folder/_config.yml文件:

deploy:
  type: 'git'
  repo: https://github.com/yourGithub/yourGithub.github.io.git
  branch: master

推送到远端

hexo d
  • 通过hexo clean可以清除之前生成的内容
  • 通过hexo g生成静态博客

更多教程请参考Documentation|Hexo


附上我的hexo博客

发布了44 篇原创文章 · 获赞 19 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/l_changyun/article/details/104089004