当前位置:网站首页>Golang application ━ installation, configuration and use of Hugo blog system
Golang application ━ installation, configuration and use of Hugo blog system
2022-06-30 22:12:00 【Use this name for the time being】
First make complaints about it , Several articles about the five elements and eight trigrams were csdn Prompt violation of national laws ... We can only consider self construction blog, Can't be tied .
Coincidentally, I have always wanted to set up a local markdown System , After all md It's always the first thing to do locally .
current hugo It's good to try , Send a document to record the installation process .
Manually download the whole process , no need git
One 、 Prepare execution file hugo.exe
Binary system
Get ready-made directly ~~
Execution file download website :https://github.com/gohugoio/hugo/releasesSource code generation
Source download website :https://github.com/gohugoio/hugo
Unzip all , Use commandgo build, There is no need for more nonsense ... ha-ha .
Be careful , If I remind youbuildno , Please check your go Is the version the latest , Used in writing this articlego 1.18.3, If it isgo 1.17.xVersion cannot be generated normally .
Two 、 Generate blogTest project
take hugo.exe Place on D:/test/hugo In the table of contents , Use cmd command
hugo new site blogTest
Generate... After execution D:/test/hugo/blogTest Catalog , This directory is the current blogTest The root directory of the project , And then put hugo.exe Move to the real root directory , Later orders need him .
3、 ... and 、 Installation template testTpl
Official template download address :https://themes.gohugo.io/
Suppose you download the template testTpl, Download and unzip to D:/test/hugo/blogTest/themes/testTpl in .
Four 、 Create articles first.md and about.md
stay D:/test/hugo In the table of contents , Use cmd command
hugo new first.md
hugo new posts/about.md
The directory and md file :D:/test/hugo/blogTest/content/first.mdD:/test/hugo/blogTest/content/posts/about.md.
about.md The contents of the document are as follows :
---
title: "About"
date: 2022-06-26T16:15:50+08:00
draft: true
---
Pay attention to this draft: true, It means this article is a draft , Later in the article .
In the end --- Write a sentence below ## ok , Test it ,markdown I don't speak much language .
5、 ... and 、 Self built server
stay D:/test/hugo In the table of contents , Use cmd command
hugo server --theme=testTpl --buildDrafts --watch
- theme: What template to use ;
- buildDrafts: Show the draft as well ;
- watch: Any article modification will be refreshed in real time ;

go server The command will automatically enable the built-in web server, It is used in the native browser by default http://127.0.0.1:1313 open , Please pay attention to the result prompt of the terminal for the specific port number .
6、 ... and 、 Generating static files
stay D:/test/hugo In the table of contents , Use cmd command
- Normal mode
hugo
- Draft also generates patterns (
-Byes--buildDraftsAbbreviation )
hugo -B
- Various command modes
hugo --theme=testTpl --buildDrafts

The generated static files are in D:/test/hugo/blogTest/public, Including articles 、 style 、 Multimedia files, etc .
At this time will be public All files in the directory can be uploaded to the hosting server for external use .
7、 ... and 、 The configuration file
There are two key configurations , If these two places are not configured , The generated static file cannot be displayed or used normally :
- The system configuration
stayD:/test/hugo/blogTest/config.tomlContent modificationbaseURLAnd newtheme.baseURLFor the project at web server Root directory on ( You can add a domain name or not , But you need to conform to the rules of absolute and relative directories ).contentIt is the local directory where the article is located , You can store the original article separately ,hugo The system belongs to another directory .themeIs the name of the template used .uglyURLsUse the title name as the file name or as the directory name , The default isfalse, If it is used locally , It is recommended to usetrue
baseURL = 'http://127.0.0.1/hugo/blogTest/public/'
contentdir = "c:/blog/test"
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = "testTpl"
uglyURLs = true
- Article configuration
takeD:/test/hugo/blogTest/content/posts/about.mdIn the articledraft: trueChange it todraft: false, Otherwise, direct usehugoIf you order , Drafts do not generate static files , It will not appear in the list of articles ,go serverThe same is true for orders .
This casefirst.mdandabout.mdThere is only... In the documentabout.mdNon draft , namelydraft: false, So usehugoCommand to generate a static file directly , There will be a homepage with only one article .
8、 ... and 、 Start blogging
If you use Obsidian Blogging , So that the accessories can be used normally , The recommended setting is shown in the figure , The key is Insert a relative path based on the current note .
The details of the obsidian Usage method :《obsidian coordination hugo Use , Give Way markdown Local editing software and online seamless connection 》
Again, I strongly recommend : In actual use, try to store the original blog in other directories ,hugo In another directory .
stay hugo Ofconfig.tomlSet incontentdirDirectory to read the original blog .
Reference resources :
Hugo Get started quickly
The world's fastest static blog generation tool Hugo Getting started tossing
Enable Ugly URL
To configure Hugo
边栏推荐
- A comprehensive understanding of gout: symptoms, risk factors, pathogenesis and management
- Introduction and example of template method mode
- About, Qianxin detects code vulnerabilities and XSS series solves them
- 阿婆做的臭豆腐
- B_ QuRT_ User_ Guide(35)
- The Three Musketeers: One for All!
- 5G 在智慧医疗中的需求
- Uniapp third party network request
- Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
- PyTorch量化感知训练(QAT)步骤
猜你喜欢

部门新来了个阿里25K出来的,让我见识到了什么是天花板

Development techniques - import files using easyexcel (simple example)

Online education program user login and registration

Do machine learning jobs require graduate students?

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)

总结的一些内存问题

How to realize the center progress bar in wechat applet

机器学习适合女生学吗?

Installing jupyter notebook under Anaconda

Is there a shortage? No need to download the free online resources! 2022 favorites must have it!
随机推荐
【BSP视频教程】BSP视频教程第19期:单片机BootLoader的AES加密实战,含上位机和下位机代码全开源(2022-06-26)
The programmer's girlfriend gave me a fatigue driving test
谈谈数字化转型的几个关键问题
PyTorch量化感知训练(QAT)步骤
1-14 express managed static resources
去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
Is machine learning suitable for girls?
1-2 install and configure MySQL related software
程序员女友给我做了一个疲劳驾驶检测
The Jenkins download Plug-in can't be downloaded. Solution
Femas:云原生多运行时微服务框架
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
从PG15 XID64再次跳票说起
Gartner focuses on low code development in China how UNIPRO practices "differentiation"
On several key issues of digital transformation
Jupyter notebook/lab switch CONDA environment
How to use data sets in machine learning?
周少剑,很少见
How to use filters in jfinal to monitor Druid for SQL execution?
Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing