Hugo: How to post new blogs

New post

Change the working directory first

cd 
cd solitary-roamer

Generate new post

hugo new post/FileName.md 

Preview the website locally (http://localhost:1313/)

hugo server -t hugo-theme-stack --buildDrafts  

Push repo to generate new public folders

hugo --theme=hugo-theme-stack -b "https://solitary-roamer.github.io/" --buildDrafts

Update blogs and anything else

cd 
cd solitary-roamer
hugo --theme=hugo-theme-stack -b "https://solitary-roamer.github.io/" --buildDrafts
cd 
cd solitary-roamer.github.io
cp ../solitary-roamer/public/* ./
cp -r ../solitary-roamer/public/* ./
git add .
git commit -m "commit"
git push -u origin main

Do everything in a brute force way

Reupload everything to the repo

cd 
rm -rf solitary-roamer.github.io 
git clone https://github.com/solitary-roamer/solitary-roamer.github.io
cd solitary-roamer.github.io
git rm -r .
git commit -m "Remove all files"
git push origin main


cp ../solitary-roamer/public/* ./
cp -r ../solitary-roamer/public/* ./
git add .
git commit -m "commit"
git push -u origin main

-u报错时,可用-f替换,强行push

git push -f origin main

commit changes to all modified files

git add -u 

Change the urls for repo (fetch and push)

git remote -v
git remote set-url origin https://github.com/Solitary-roamer/Solitary-roamer.github.io.git
git remote -v

https://github.com/Solitary-roamer/Solitary-roamer.github.io.git

is the same as

https://github.com/solitary-roamer/solitary-roamer.github.io.git