听阳光的猫

道阻且长、望你如一

0%

使用Hugo搭建个人博客

使用之前需要先安装好git

一、安装Hugo

window系统

https://github.com/gohugoio/hugo/releases 访问当前路径下载

image-20201111155951520

mac系统

​ 使用brew工具安装 brew install hugo

hugo version 查看是否安装成功

二、用Hugo来生成博客

hugo new site myblog

三、下载并设置主题

https://themes.gohugo.io/ 里面有各种各样的主题

git clone https://github.com/vaga/hugo-theme-m10c.git themes/m10c 下载主题

cd themes 查看文件夹是否存在

ls 列出目录下的文件

ls -l 提供了一个简单的目录列表

pwd 查看默认工作目录的完整路径

四、在本地启动个人博客

hugo server -t m10c --buildDrafts 在本地启动,预览

五、实际写一篇文章

hugo new post/blog.md

​ 可以使用vscode打开编辑

六、将个人博客部署到远端服务器

hugo --theme=m10c --baseUrl="https://YourGithubName.github.io" --buildDrafts

​ 将public 文件夹传到GitHub上

cd public/

git int

git add .

git commit -m "hugo博客"

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

git push -u origin master

https://YourGithubName.github.io/ 访问博客