Preface
My first website was built by WordPress, but WordPress is not specially developed for personal blogs, there are many functions that are completely unused, which slow down the loading speed. So I want choose a new framework for blog, between Hexo and Hugo I finally chose Hugo, here is why.
Hugo | Hexo | |
---|---|---|
Language | Go | Node.js |
Plugins | No | Yes |
HTML Anchor | Yes | No |
Development | Easy | Hard |
My blog is generally pure text, with few pictures. The requirement is fast loading and easy customization, so I choose Hugo. As the slogan: “The world’s fastest framework for building websites.” Hugo just spend 1988 ms to generate a site which 1000 pages, and Hexo need 5138 ms.
But Hexo has a great advantage as the most popular framework, there are many beautiful themes, such as Typography . I fell in love with it at first sight, but since it doesn’t support sidebar, I recommended it to Xia, and now it’s used in 永七茶話會 .
1. Download & Config
1.1 Download
Download Hugo
and run hugp version
to check whether the installation is successful. If successful, add hugo
to the environment variables.
Then run hugo new site <sitename>
to crate a new site, which file tree is like
|
|
Here I recommend you change
config.toml
=>config.yml
, Because theyml
file is highly readable.
Download theme your liked in themes
folder, for example: PaperMod
.
|
|
1.2 Config
Refer to the exampleSite
folder to modify config.yml
, for PaperMod, there is not built-in(Many themes come with it), we have to check PaperMod Example
or Wiki
.
Although different themes have different config.yml
, the following are the same
|
|
2. Usage & Publish
2.1 Default Front Matter
Setting default Front Matter is very important, it can save our time, so we can focus on writing. open archetypes/_default.md
|
|
2.2 Commands
|
|
Here [flags]
is optional, all available commands is following
|
|
Use hugo [command] --help
for more information about a command.
Here are some commands
Crate new site
|
|
Crate new post in content
folder.
|
|
Create a file at a specified location, such as
posts/Tech/postname.md
1
hugo new posts/Tech/postname.md
Local preview webserver in 127.0.0.1:1313
or localhost:1313
, here -D
means include content marked as draft.
|
|
Use Hugo to render Markdown files into HTML.
|
|
hugo
only crate new file inpublic
folder, but don’t delete old. If you want delete that, run
1
hugo -F --cleanDestinationDir
2.1 Publish
All HTML files are ai public
folder, upload the folder to site index on your server. If you want uploading to the hosting platforms, refer to hosting Hugo
.
Here I recommend Banwagon or Vultr , if you want purchase a server.
Epilogue
From my experience, frameworks are unnecessary, the important thing is to keep writing. I know a lot of people, their website is very beautiful, but after half a year, if look at it again, you will find that he has not insisted on writing, and the website is deserted.