雄关漫道真如铁,
而今迈步从头越。
从头越,
苍山如海,残阳如血。
0x00 环境搭建
installation
下载得到hugo.exe
链接名称
# macos
brew install hugo
# linux
sudo apt/yum install hugo
配置环境变量
安装成功
λ hugo -h
hugo is the main command, used to build your Hugo site.
Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.
Complete documentation is available at http://gohugo.io/.
Usage:
hugo [flags]
hugo [command]
Available Commands:
config Print the site configuration
convert Convert your content to different formats
deploy Deploy your site to a Cloud provider.
env Print Hugo version and environment info
gen A collection of several useful generators.
help Help about any command
import Import your site from others.
list Listing out various types of content
mod Various Hugo Modules helpers.
new Create new content for your site
server A high performance webserver
version Print the version number of Hugo
0x01 创建网站
创建新站点(文件夹)
hugo new site web_blog
blog
├── archetypes
├── config.toml //全局配置文件
├── content //文章发布目录
├── data
├── layouts
├── static
├── themes——| //主题目录
|——hugo-theme-dream———exampleSite //模版目录
└── public //编译发布目录
配置
cd web_blog
# 下载主题
git clone https://github.com/digitalcraftsman/hugo-agency-theme themes/hugo-theme-dream
# 本地启动
hugo server -t hugo-agency-theme --buildDrafts
Start building sites …
| EN
-------------------+-----
Pages | 14
Paginator pages | 0
Non-page files | 0
Static files | 44
Processed images | 0
Aliases | 3
Sitemaps | 1
Cleaned | 0
Built in 78 ms
Watching for changes in D:\hugo_blog\{archetypes,content,data,layouts,static,themes}
Watching for config changes in D:\hugo_blog\config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
# 编译生成静态网站
hugo --theme=hugo-theme-dream --baseUrl="https://geekzzy.github.io/" --buildDrafts
写文章
# 创建新文章
hugo new post/blog.md
# 文章属性
title: xxx
date: 2021-01-12T23:54:31+08:00
lastmod: 2021-01-12T23:54:31+08:00
author: geeekzzy
avatar: /me/yy.jpg
cover: 文件路径
categories:
- xxx
tags:
- xxx
- xxx
0x02 GitHub Pages
git配置
# 初始化
git init
# 添加所有文件到仓库
git add .
git commit -m "我的博客"
# 添加远程仓库源
git remote add origin https://github.com/geekzzy/geekzzy.github.io.git
//git pull origin master --allow-unrelated-histories
# 推到远程仓库的master分支
git push -u origin master
更新文章
# 本地更新
# 推送到远端
git add .
git commit -m "我的博客"
git push -u origin master