当前位置:网站首页>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
边栏推荐
- How to judge whether the JS object is empty
- Microservice link risk analysis
- A new one from Ali 25K came to the Department, which showed me what the ceiling is
- B_ QuRT_ User_ Guide(31)
- 5G 在智慧医疗中的需求
- Summary of errors reported when using YML file to migrate CONDA environment
- Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
- 《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19
- Uniapp routing uni simple router
- Mysql:sql overview and database system introduction | dark horse programmer
猜你喜欢

Introduction to go web programming: a probe into the excellent test library gocovey

Pytorch quantitative practice (2)

Windbg调试工具介绍

PostgreSQL存储结构浅析

谈谈数字化转型的几个关键问题

十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?

Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing

Look at the top 10 capabilities of alicloud cipu

Web APIs comprehensive case -tab column switching - dark horse programmer

Niubi | the tools I have treasured for many years have made me free to fish with pay
随机推荐
VIM common shortcut keys
1-20 pre inspection request
Uniapp rich text editor
Look at the top 10 capabilities of alicloud cipu
机器学习中如何使用数据集?
1-11 create online file service
1-17 express Middleware
Apache服务器OpenSSL升级
1-2 install and configure MySQL related software
1-18 create the most basic express server & API module for creating routes
Is there a shortage? No need to download the free online resources! 2022 favorites must have it!
Jupyter notebook/lab switch CONDA environment
Win11如何优化服务?Win11优化服务的方法
Installing jupyter notebook under Anaconda
Stinky tofu made by Grandma
Pytorch quantitative practice (2)
Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
Anfulai embedded weekly report no. 270: June 13, 2022 to June 19, 2022
HDFS centralized cache management