title: “安装配置hugo”
date: 2021-12-05T12:50:03+08:00
draft: true
初始配置
官网下载
https://github.com/gohugoio/hugo/releases
下载目录:
C:\Users\Administrator\go\src\HugoMyblog
安装配置
解压安装
查看版本
root@wangwei830:/opt/blog# ./hugo version
hugo v0.89.4-AB01BA6E linux/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio
创建myblog目录及配套文件:
root@wangwei830:/opt/blog# hugo new site myblog
Congratulations! Your new Hugo site is created in /opt/blog/myblog.
Just a few more steps and you're ready to go:
1. Download a theme into the same-named folder.
Choose a theme from https://themes.gohugo.io/ or
create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".
Visit https://gohugo.io/ for quickstart guide and full documentation.
调整目录:
把解压的出来的命令文件剪切到myblog目录下
下载模板:
root@wangwei830:/opt/blog#
cd /opt/blog/myblog/themes
git clone https://themes.gohugo.io/themes/hugo-theme-learn/
本地启动服务:
root@wangwei830:/opt/blog/myblog# hugo server -t hugo-theme-learn --buildDrafts
Start building sites …
hugo v0.89.4-AB01BA6E linux/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio
| EN
-------------------+-----
Pages | 7
Paginator pages | 0
Non-page files | 0
Static files | 75
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Built in 55 ms
Watching for changes in /opt/blog/myblog/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /opt/blog/myblog/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)
Press Ctrl+C to stop
新建一篇文章
C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog> .\hugo.exe new post/安装配置hugo.md
然后写入文章内容
站点托管
创建仓库与用户同名
简易的命令行入门教程:
Git 全局设置:
git config --global user.name "汪伟"
git config --global user.email "wangwei198484@163.com"
创建 git 仓库:
mkdir wangwei830
cd wangwei830
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/wangwei830/wangwei830.git
git push -u origin master
已有仓库?
cd existing_git_repo
git remote add origin https://gitee.com/wangwei830/wangwei830.git
git push -u origin master
绑定地址
绑定地址后会生成一个pbulic文件夹
PS C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog> .\hugo.exe --theme=hugo-theme-learn --baseUrl="https://wangwei830.github.io/" --buildDrafts
Start building sites …
hugo v0.89.4-AB01BA6E windows/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio
.File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}
| EN
-------------------+-----
Pages | 10
Paginator pages | 0
Non-page files | 0
Static files | 75
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 543 ms
PS C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog>
推送public目录内容
cd public
git init
git add .
git commit -m "20211205"
git remote add origin https://gitee.com/wangwei830/wangwei830.git
git push -u origin master
仓库开启Pages服务
需要身份证
访问博客
wangwei830.git.io
使用
更新文章内容
cd C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog
.\hugo.exe --theme=hugo-theme-learn --baseUrl="https://wangwei830.github.io/" --buildDrafts
发表新文章
cd C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog
.\hugo.exe new post/安装配置hugo.md
.\hugo.exe --theme=hugo-theme-learn --baseUrl="https://wangwei830.github.io/" --buildDrafts
跟换新模板
cd C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog\themes
git clone https://themes.gohugo.io/themes/hugo-book/
git clone https://github.com/alexandrevicenzi/soho
新模板启动本地blog服务
cd C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog
.\hugo.exe server -t soho --buildDrafts
目录设计
cd C:\Users\Administrator\go\src\HugoMyblog\hugo_0.89.4_Windows-64bit\myblog
# 操作系统
.\hugo.exe new Linux/init.md
.\hugo.exe new Aix/init.md
.\hugo.exe new HPUX/init.md
.\hugo.exe new Windows/init.md
# 数据库
.\hugo.exe new Mysql/init.md
.\hugo.exe new Postgres/init.md
.\hugo.exe new Oracle/init.md
.\hugo.exe new Tidb/init.md
.\hugo.exe new DB2/init.md
.\hugo.exe new Informix/init.md
# 开发
.\hugo.exe new Python/init.md
.\hugo.exe new Golang/init.md
.\hugo.exe new Csharp/init.md
.\hugo.exe new Shell/init.md
# 未分类
.\hugo.exe new Other/init.md
#主页
.\hugo.exe new _index.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md
.\hugo.exe new Linux//init.md