Hugo deploy on Github
Created two repositories, blog and actual blog with the github name (githubname.io). Set the repositories to public, the second one is actual blog with the githubname url. The first repository can be set as private if we need to use it in different platforms.
-
clone the blog repo to the local
-
create the new hugo site using hugo new site [. (current direcoty)] or [name of folder]
-
cd themes and clone specific theme from github, and config toml file to set theme
-
hugo server or hugo server -D to test local blog server
-
using hugo new posts/post_name.md to add content
-
Set the production repo with main branch, add the a readme file to this repo.
git checkout -b maintouch README.md -
add submodule to public folder
git submodule add -b main [https production repo url] public -
build content with the theme before deploy
hugo -t [theme name] -
cd public folder and push all content to github
git add .git commit -m "init"git push origin maingithub wil automatically deploy the site from the main branch, the production repository is the whole content in the public folder.
-
Test the new feature of youtube video Ask about this video
refer to https://www.youtube.com/watch?v=LIFvgrRxdt4&t=83s
Configure the toml file
Added the last edited date behind the date created of each post
enableGitInfo = true
[frontmatter]
lastmod = [':git', ':fileModTime']
Repository test
The method for moving all folders in the first repository to new platform.
- git pull the first blog repository
- check the remote repository in public folder
- if the remote repository is not production reposition, then remove the folder, and add submodule through the production reposition url again.
- also check the theme folder if it is empty, and clone it from github as needed.
Image rendering
Image rendering issue solved by created a static folder under the root directory,then put all images to a img folder in static folder and check the base url in toml file, it the baseURL is https://xxx.xxx.com, the markdown syntax would be written as

if the baseURL is https://xxx.xxx.com/xxx.xxx.xxx. try

the local markdown preview in vscode doesn’t work for this syntax, and it can be used to assist viewing the content when browser isn’t rendering the images. Based on the above solution, the browser works well.
