# 安装 sudo apt install hugo # 手动安装 wget https://github.com/gohugoio/hugo/releases/download/v0.54.0/hugo_0.54.0_Linux-64bit.deb sudo dpkg -i hugo_0.54.0_Linux-64bit.deb # 查看 hugo --help hugo version
建立博客
新建git文件夹用以git模板等,并在文件夹下新建myblog,用来存放博客页面
1 2 3 4 5
# 新建git文件夹并git初始化 mkdir gitFile git init # 新建myblog文件夹用来存放博客页面 hugo new site myblog
enableOpenGraph = true enableTwitterCards = true title = "My Blog" description = "My HomePage Description"
[taxonomies] ros = "Ros" blog = "Blog"
[[menu.main]] url = "/blog" name = "Blog" weight = 1 [[menu.main]] url = "/ros" name = "Ros" weight = 2
创建文章
默认主目录文章在content/post下
1 2 3 4 5 6 7
# 创建文章 hugo new post/my_first_blog.md #创建文章在需要目录(Archive)下 hugo new posts/my_first_blog.md cd content/post nano my_first_blog.md # 注意将draft参数改为false,否则跳过草稿文件,无法预览
进入仓库,点击Settings进入,找到GitHub Pages并点击Check it out here!,配置Source并save,会发现绿色框中显现 Your site is published at https://peitianyu.github.io/pty_blog.github.io/
# 新建博客markdown文件,并编辑博客内容(文件名为 **.md ) hugo new post/newBlog.md # 生成静态页面 hugo --theme=diary --buildDrafts --baseUrl="https://peitianyu.github.io/pty_blog.github.io/" # 发布 cd public git add . git commit -m "new blog added" git push origin master