2023-06-02 hexo推送至github

发布时间 2023-06-02 16:17:28作者: 哎呦你可棒棒了

第一步:

在你的hexo博客根目录打开终端输入以下命令:

npm install hexo-deployer-git --save

第二步:配置根目录的_config.yml文件:

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://你的github名.github.io/
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

...

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repository: https://github.com/你的github名/你的github名.github.io.git
  branch: master

第三步:执行hexo d,该命令会把hexo的public文件推送至github

注意:如果推送的时候报错:

fatal: unable to access 'https://github.com/你的github名/你的github名.github.io.git/': Recv failure: Connection was reset

那么大概率就是网络问题,连接不上github,这时候重新尝试多几次hexo d就行了。