用hugo搭建个人博客

应用一些博客框架快速搭建博客

Posted by Zhao Zihao on December 17, 2020

可以使用hexo,hugo等静态网站生成器生成个人博客,这里介绍了用hugo搭建个人博客

安装hugo

# brew安装
brew install hugo
# 检查hugo版本
hugo version 

生成站点(生成一个空的本地文件夹,用于存放站点内容)

hugo new site myblog 

进入myblog

cd myblog 

下载喜欢的主题

例:下载地址:themes.gohugo.io 主题选择:m10c

git clone https://github.com/vaga/hugo-theme-m10c.git themes/m10c 

运行hugo

hugo server -t m10c --buildDrafts 

写文章,新建markdown文本,使用编辑器进入相应目录编写(/content/post/)

hugo new post/blog.md 

部署到Github

首先在GitHub上创建一个Repository,命名为:Colinasda.github.io (Colinasda替换为你的github用户名)。

关联远端地址并生成最终页面

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

在public文件夹中,进行如下操作进行push:

cd public
git init
git add .
# 提交的信息
git commit -m "我的hugo博客第一次提交"
# 与github关联
git remote add origin https://github.com/Colinasda/Colinasda.github.io.git
# push,输入用户名&密码
git push -u origin master

浏览器里访问:http://Colinasda.github.io/