第一篇正式博文,我想给你们分享下个人博客的建立过程吧!⭐️git
Hugo 是由 Go 语言实现的静态网站生成器。简单、易用、高效、易扩展、快速部署。程序员
官方教程 英文github
Mac 安装方式post
brew install hugo网站
hugo versionui
Windows 安装方式spa
hugo version
查看版本
官方文档教程,必看!code
新建 blog 目录,运行 hugo new site xxx.github.io-generator
, xxx 为 github 用户名 。会在当前目录中建立 xxx.github.io-generator 文件夹(博客生成器)server
进入博客生成器目录,git init
blog
选择并下载主题 ,放到 themes 目录下 git clone https://github.com/dillonzq/LoveIt.git themes/LoveIt
遇到报错 ↘
fatal: unable to access 'https://github.com/dillonzq/LoveIt.git/': error setting certificate verify locations:
CAfile: D:/Software/Git/mingw64/ssl/certs/ca-bundle.crt
CApath: none
复制代码
解决办法:使用 git clone 出现 fatal: unable to access 'https://github.com/...'
,执行代码 ↓
git config --system http.sslverify false // 把证书校验禁用
复制代码
而后,将主题添加到站点配置中:echo 'theme = "LoveIt"' >> config.toml
// 主题目录的名称
建立新文章:hugo new posts/first_post.md
D:\blog\xxx.github.io-generator\content\posts\first_post.md
created
编辑文章后,修改 draft: false
。draft : true 表示处于草稿状态,此时Hugo不会真正发布它
初次建立博客或修改主题,需将主题文档中给出的配置,粘贴到 config.toml
文件中。
baseURL 配置成 http://[用户名].github.io/
hugo server -D
创建本地访问 https://localhost:1313 预览博客
hugo
建立一个新的目录 public/,这就是须要提交到 github,最终生成线上博客的目录
根目录下,新建 .gitignore
文件,添加 /public/
。使得 /public 能够自成一个仓库
进入public cd public
,git init
git add .
git commit
[用户名].github.io
。git remote add origin xxx
git push -u origin master
hugo new posts/第二篇博客.md
code posts/第二篇博客.md
对文件进行编辑,注意不要把文件本来的内容 front matter 给删了,直接在后面另起一行写新内容。hugo server -D
创建本地访问 https://localhost:1313 预览博客hugo -D
,获得新的 public 目录cd public
,执行一下操做
git add .
注意有一个点git commit -m update
git push -f
其中 -f 是强制上传的意思
程序员永远都会留备份
新建仓库 xxx.github.io-generator
将本地 xxx.github.io-generator 目录,git init
,git add .
,git commit -m backup
,git remote add origin xxx
,git push -u origin master
便可