windows下blog的搭建
官方网站
1.安装hugo
在https://github.com/gohugoio/hugo/releases找到相应版本的hugo镜像,下载后解压,如下:
配置环境变量:将解压后压缩包放在E盘,则添加如下环境变量
输入如下命令判断是否按照成功
hugo version
2.建立站点
使用如下命令(blog为路径名)
hugo new site blog
cd blog
生成目录如下
3.增加文章
输入以下命令后会在content里创建一个文件
hugo new about.md
打开文件,
---
title: "About"
date: 2019-05-31T15:47:28+08:00
draft: true
---
4.安装主题
主题选择的是LeaveIt,安装后会在themes中生成对应文件
cd themes
git clone https://github.com/liuzc/LeaveIt.git
并在config.toml中配置如下
theme = "LeaveIt"
4.运行hugo
hugo server -D
5.配置
在content中新建文件夹posts,并在config.toml中加入配置如下:
# 菜单的配置
[menu]
[[menu.main]]
name = "博客"
url = "/posts/"
weight = 1
[[menu.main]]
name = "分类"
url = "/categories/"
weight = 2
[[menu.main]]
name = "标签"
url = "/tags/"
weight = 3
[[menu.main]]
name = "关于"
url = "/about/"
weight = 4
在建新文章时,categories中为文章分类,tags为标签。
---
title: "代理模式"
date: 2019-05-29T20:06:16+08:00
draft: false
categories: ["Java"]
tags: ["Java","设计模式"]
---
#### 内容
5.部署
部署到GitHub Pages 上,首先在GitHub上创建一个Repository,命名为:pallcard.github.io (pallcard替换为你的github用户名)。
hugo --theme=LeaveIt --baseUrl="http://pallcard.github.io/"
将pubilc目录里所有文件 push 到刚创建的Repository的 master 分支。
cd public
git init
git remote add origin https://github.com/pallcard/pallcard.github.io.git
git add -A
git commit -m "first commit"
git push -u origin master
浏览器里访问:http://coderzh.pallcard.io/
6.注意
1.每次使用hugo new posts/xxx.md创建文章后,记得要将draft 改为false
2.更新部署时,在根目录执行hugo,然后push到github上即可