Joke Collection Website - Blessing messages - Use GitHub-Actions to automatically publish Hugo blog to GitHub and Gitee pages.

Use GitHub-Actions to automatically publish Hugo blog to GitHub and Gitee pages.

Personal blogs nowadays usually have many choices. If you don't want to buy a server to publish a static blog, you can set up your own account and publish it on platforms such as CSDN, but the original data cannot be managed locally. If you want to manage data completely by yourself, you can publish your own blog using GitHub or Gitee Pages, and use mature static blogs such as Hugo or Hexo to convert md files into static website files for quick publishing. This article is used to record how to quickly publish blogs to three platforms: GitHub and Gitee pages.

Of course, I hope that the process is mainly to write articles, and it is best not to handle the publishing process manually at all, but the actual process of publishing blogs manually is roughly as follows:

Previously, Travis CI+GitHub+Hexo was used to automatically publish to GitHub pages, but the access of GitHub was often unreliable, so I thought I could synchronize to Gitee, and the speed of automatically building Hexo was affected by the deployment of Nodejs environment, which was very slow. So this time Hugo is used to build website files, and the overall process design is as follows:

In order to meet the automatic publishing process of blogs, we need to prepare a local production environment to meet the rapid publishing, so complexity is for long-term simplicity. So in the stage of environmental preparation, I will record all the tools involved, which is convenient for everyone to use and review later. Environmental preparation includes:

Obsidian after the completion of knowledge accumulation, according to->; Project-> Archive-> Blog process publishes blogs, but Obidian files are interrelated. How to reuse attachments quickly requires simple configuration of Typora and Obidian to ensure that subsequent blogs can be published quickly and the files are still displayed normally in Obidian projects.

Typora is very concise and can be previewed in real time. When writing a blog, I often insert some pictures. After the screenshot, I can paste them directly, and the pictures will be automatically saved locally. Here, you need to pay attention to the storage path of the picture. In preferences, set the replication path (. /resource/) When inserting a picture, the copied picture will be automatically saved in the resource folder under the current folder, which is convenient for subsequent management and transfer.

Generate id_rsa and id_rsa.pub in. Ssh file;

Hugo is a static blog framework based on go language, which is known as the fastest website building tool in the world.

The command is hugo's new website myblog.

Myblog is the directory name of the blog, which can be changed to the name you want. The generated directory is as follows:

Because some functions of the article page generated by the default theme are unnecessary, you need to modify the files under the theme:

Copy the three directories of config, content and themes into the newly created site directory, and replace the content with the article file.

Utterances is a Github tool based on Github Issue. Its advantages are no advertisement, fast loading speed, simple configuration, light weight and open source.

Since utenances is a Github App, it is very simple to install utenances, just give utenances a specific repurchase right. Note: the authorized repurchase must be open, and multiple repurchases can be selected, but it is recommended to choose one, which is also safer.

This is the simplest configuration method at present. You can also check the detailed configuration parameters in other configuration methods and discourses.

For the installation and use of Obsidian, please refer to my other article: Basic use and configuration of Obsidian as a second brain tool.

After all the environments are ready, it's finally time to start our automation process.

As in the previous steps, configure the Gitee password as GitHub Secrets and name it GITEE_PASSWORD. All configuration results are as follows:

synctogitee.yml

You need to bind the Gitee account to the official WeChat account. Otherwise, in the last step, the reloading page will automatically deploy the Gitee page, and you will not be able to log in because you need SMS verification. After binding the official WeChat account, there is no need for SMS verification; Please refer to gitee-pages-action for other problem solving.

After Typora finished writing the article, she uploaded all the pictures to Gitee with one click, copied and published them to, and then submitted them to the main branch of GitHub repurchase, which can be automatically deployed to GitHub and Githue pages; ;

The above is what I used GitHub-Actions to automatically publish Hugo blog to GitHub and Gitee pages, hoping to help you build your own personal website quickly. I will continue to improve the ideas and methods of building my second brain system.