Note on Deploying a Personal Website on Github
Contents
Create a Markdown File
- Write note with Markdown.
Convert the Markdown File to a Local Website
Install hugo and configure the website folder
- Install Hugo following the guidance.
- Install powershell.
- Open
powershelland change the directory to the location you want to place the website files by runningcd <loc>. - Create a new site using Hugo by running
hugo new site <site_name>inpowershell. - Edit the
hugo.tomlfile, leavingbaseURLempty for now. - Change the directory to the website folder in
powershell. - Create a document content by running
hugo new docs/test.md.
Install the theme and add contents
- Run
git init. - Find a nice theme at Hugo –> Download –> Install (run the
git clonecommand under method 1 and rugo n thegit submodule addcommand under method 2). - Edit the
hugo.tomlfile, addingtheme = <theme_name>. - Edit the content file, setting
drafttofalseand add some contents. - Run
hugo serverand access it locally athttp://localhost:1313/.
Deploy the Website on Github
Push website framwork to Github
- Create an empty github repository.
- Copy the
git remote add origin <website_path>.gitcommand. - Add a
README.mdfile and git push –>git add README.md–>git commit -m "initial commit"–>git branch -M main–>git remote add origin <website_path>.git->git push -u origin main.
Setup a branch for Github pages
- Create a
gh-pagesbranch. - Go to repository’s
settings–>action–>general–> enableRead and write permissions–>save.
Create a Github workflow
- Create an empty file in your local repository at
.github/workflows/hugo.yml. - Copy the YML specified in Deploying a Blog Powered by Hugo to Github Pages w/ Custom Domain via Github Actions to the
hugo.ymlfile. - Update the Hugo source link,
user.name, anduser.emailin thehugo.ymlfile. - Modify the
hugo.tomlfile –>baseURL = 'https://nagato-D.github.io/<repo_name>/'.
Git push
- Run
git add .–>git commit -m "add the first test page"–>git push. - Waiting for Github to deploy your website.
- Access your website at
https://<user_name>.github.io/<repo_name>/.
How to Update the Website
- Add (
hugo new <path/filename>) or modify the markdown files in thecontentfolder (remember to setdraftkeyword tofalsefor markdown files in thecontentfolder). - Run
hugo serverto rebuild the website locally. - Post the website online:
git add .–>git commit -m "message"–> git push. - Verify the release.
How to Configure Website
- Copy the contents in
themes/<theme_name>/config.tomltohugo.toml. - Modify the parameters specified in
hugo.toml, such as website title, avatarURL, and social links. - In order to add a menu in the homepage, like the tags in the right top, following the menu setting in the
config.tomlfile to configure thehugo.tomlfile in the website root directory. - A recommended file structure/organization of the contents can be found here.
- To enable the display of LaTeX-style equations, set
enable = trueunder theparams.page.mathitem ofhugo.toml.
Add Icons
-
LoveIt utilizes the icon library provided by Font Awesome for seamless integration of icons into your content.
-
Icon references adhere to markdown syntax. To incorporate an icon, simply use the format
:icon_name:, where the specificicon_namecan be found on the Font Awesome website. -
As an illustration, let’s say you want to insert a code icon. You can locate the corresponding HTML code here, which is
<i class="fa-solid fa-code"></i>. Subsequently, you can introduce the code icon using:fa-solid fa-code:, with thefa-solid fa-code(namelyicon_name) derived directly from the HTML code.