当前位置:网站首页>Hugo blog building tutorial

Hugo blog building tutorial

2022-06-13 04:14:00 Cun Yuyao

Preface

With utilization Hexodocsifyvuepress Wait for the framework to build the blog experience , Let's take a look today Hugo.Hugo It's based on Go Language and the implementation of the static web site generator , It is simple and easy to use 、 Efficient and easy to expand 、 Features of rapid deployment .

Let's start with Hugo Official documents in Chinese and English , It is convenient for everyone to consult when encountering problems :

  1. Hugo Chinese document
  2. Hugo English document

Let's take a look , How to use it Hugo To build a blog .

Set up process

install Hugo

Since you want to use Hugo, You need to install it first . If you want to install through binary installation package , First of all, you need to choose the installation package suitable for your platform , Then download it .

Download link

Here is not only suitable for Windows Installation package of platform , It also includes Linux The platform and macOS Installation package of platform . More Than This , For different users , Also carefully provided 32 Bit and 64 Bits to choose from . Even for chips of different architectures, corresponding installation packages are provided , Can be said to be very careful .

But my demonstration here is mainly based on macOS platform , So I will not install it in the form of installation package , Through here homebrew One line of command can be easily done .

brew install hugo

If your macOS Is not installed on homebrew, Then hurry to install it .

Here's a warm reminder , Domestic users shall comply with homebrew Basically, the installation through the official website will fail , So here is another installation method , Install through the following script .

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

Check for success

Although after installation through the above command , The console prompts us that the installation is successful , But we have no idea , Just want to see if the low installation is successful . At this time, you can view Hugo The way the version number is , Laique Hugo Is the installation successful .

hugo version

If the installation is successful , Then after executing the order, it will be like the above , Prompt you for the installed Hugo Version of .

Initialize the website

Now that it's installed , The next step is to initialize our website directory . By the following command , We can accomplish Hugo The project is initialized !

hugo new site [ Project name ]
hugo new site JavaPark

After the project is initialized , The resulting directory is as follows .

Here we need to pay attention to config.toml , This is the configuration file for the project , Mainly used to configure Hugo, The configuration in this file will be valid for the whole project .theme The directory is mainly used to place topics , There is usually one inside theme.toml, Used to configure the theme .

By default ,config.toml There will only be the following three configurations .

Set the theme

To style our website , We need to choose a favorite topic .Hugo It's not like Hexo Provides more topics , But there are still many good ones , You can go to the skin list to find .

Skin list

Here I choose a skin m10c, Enter the project we initialized , Then use the following command to download the topic to theme Under the folder .

git clone https://github.com/vaga/hugo-theme-m10c.git themes/m10c

Then go to the project configuration file config.toml in , Set the theme .

theme = "m10c"

preview

After setting the theme , You can preview ! Start with the following command Hugo The server , Then enter http://localhost:1313 You can preview !

hugo server -D

summary

The above is how to use Hugo Set up a blog , Mainly from Hugo install 、 Initialize project 、 Theme Settings 、 Preview and other aspects Hugo Use , The rest is writing . It's a very difficult thing , I hope you can stick to it . Actually Hugo There are many other ways to play , I won't introduce them one by one here , You can go to the official website to explore more ways to play .

原网站

版权声明
本文为[Cun Yuyao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130400465053.html