基于hugo的个人博客

基于hugo的个人博客

参考文档:https://www.gohugo.org/

1.安装hugo

  1. 直接在hugo官方GitHub下载相应版本然后解压

  2. Windows需添加软件所在路径到path

  3. Mac可直接使用Homewbrew下载

    brew install hugo
    

Windows使用注意: 之后执行的命令在cmdGit bash均可,git相关命令只能在Git bash里执行

2.生成站点

快速生成站点,比如希望生成到当前路径下的myblog路径

hugo new site myblog

3.创建文章

创建一个about页面

hugo new about.md

一般都放到post目录下,方便之后生成聚合页面

hugo new post/about.md

在站点根目录(即myblog目录)下执行,将生成到myblog/content/目录下

生成的文件由开头为如下

---
title: "about"
date: 2019-08-14T20:34:19+08:00
draft: true
---

draft为草稿的意思,将其值改为"false"

4.安装皮肤

皮肤列表挑选一个心仪的皮肤,如:polymer ,找到相关的GitHub地址,到myblog/themes/目录里把皮肤git clone下来

cd myblog/themes/
git clone https://github.com/pdevty/polymer.git

polymer的配置:https://themes.gohugo.io/polymer/

5.运行hugo

在站点根目录(即myblog目录)下执行

hugo server --theme=polymer --buildDrafts

可在https://localhost:1313访问

6.部署

假设你需要部署在GitHub Pages上,首先在GitHub上创建一个Repository,命名为:tricenull.github.io(tricenull替换为你的github用户名)

在站点根目录执行Hugo命令生成最终页面:

hugo --theme=polymer --baseUrl="https://tricenull.github.io/" --buildDrafts

将会在站点根目录(即myblog目录)下生成public目录,将pubilc目录里所有文件push到刚创建的Repositorymaster分支

cd public
git init
git remote add origin https://github.com/TRiceNull/tricenull.github.io.git
git add -A
git commit -m "first commit"
git push -u origin master

7.更新博客

在站点根目录myblog打开Git bash

hugo new new.md
hugo server --theme=polymer --buildDrafts
hugo --theme=polymer --baseUrl="https://tricenull.github.io/" --buildDrafts
cd public
git add -A
git commit -m "first commit"
git push -u origin master

注意:new.md文件中draft的值改为"false"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值