Using Hugo to create a blog with static pages under Debian

888u

Last update at :2024-05-27,Edit by888u

All are done under the command line. It may seem complicated to novices, but in fact it is just a step-by-step process. This article was successfully built under Debian 7 6-bit.

First upgrade the system and install git

apt-get update apt-get install git

1. Install go1 and download go

cd /tmp wget --no-check-certificate https://dl.google.com/go/go1.10.linux-amd64.tar.gz

The version used is go1.10, you can also use other versions.

tar -C /usr/local -xzf go1.10.linux-amd64.tar.gz

2. Add configuration files (located in the /root directory, such files ~/.bashrc, ~/.zshrc)

export PATH=$PATH:/usr/local/go/bin export GOROOT='/usr/local/go' export GOPATH='/home/root/projects/go' export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN

Change root in /home/root/projects/go to your own username, I use root directly

3. Activate environment variables and create directories

cd /root source ~/.bashrc mkdir -p $GOPATH

The Golang environment is now installed.

2. Install hugo and create a blog 1. Install hugo

go get -u -v github.com/gohugoio/hugo

2. Use hugo template to create a blog

cd $GOPATH/src/github.com/gohugoio/hugo/examples/ cp -r blog /tmp/static-site-hugo cd /tmp/static-site-hugo hugo hugo server -b "URL" --bind "IP_ADDR" -p 9999

URL is your bound domain name, you can also use ip, IP_ADDR real-time server IP, 9999 is the access port, so you can use the domain name or IP: 9999 to access

3. Start adding blog posts in the /tmp/static-site-hugo/content/post/ directory and create a file ending with .md, such as 001.md. Use markdown syntax.

cd /tmp/static-site-hugo/content/post/ vi001.md

Add it in the following format

--- title: "First article, test" description: "We test hugo" date: "2018-04-02" categories: - "kvm" - "openvz" tags: - "virmach" - "ramnode" - "blog" --- The first test blog post, from us

. 4. Use screen to run the website in the background a. Install screen

apt-get install screen

b. Enter the blog directory and create a session

cd /tmp/static-site-hugo screen -S hugo

c. Run hugo so that the blog can access hugo server -b “URL” –bind “IP_ADDR” -p 9999d. When you need to add an article, ctrl + c stops running hugo, and then enters exit to stop running screen. After adding the article, repeat the command to create a session (steps b and c). According to the citation author's introduction, hugo will automatically update some changes, and you can edit them in between.

5. Modify templates and blog posts are in the /tmp/static-site-hugo directory. It is recommended to use WinSCP software to edit and upload directly. In the /tmp/static-site-hugo/layouts/partials directory, you can modify the header, bottom, columns, sidebars and other information.

Demo: http://137.175.66.54:9999/

Partial reference: https://wooservers.com/blog/build-your-first

Recommended site search: Hong Kong cloud server 10 yuan a year, free IP address in mainland China, host space, domain name registration network, server rental price, foreign server, website registration, which Hong Kong space is good asp free space application, free mainland China space,

Using Hugo to create a blog with static pages under Debian

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码