blog快速搭建-hugo

windows下blog的搭建

官方网站

https://www.gohugo.org/

1.安装hugo

在https://github.com/gohugoio/hugo/releases找到相应版本的hugo镜像,下载后解压,如下:
windows
配置环境变量:将解压后压缩包放在E盘,则添加如下环境变量
环境变量
输入如下命令判断是否按照成功

hugo version

检查安装

2.建立站点

使用如下命令(blog为路径名)

hugo new site blog
cd blog

生成目录如下
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上即可

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值