hugo quick start to build your website and deploy to github in ten minutes
By 前端关宇
Precondition
- mac pro
- brew
- git
1: Install Hogo
brew install hugo
To verify your new install:
hugo version
2: Create a new site
hugo new site quickstart
quickstart 就是自己起的目录名
3: Add a Theme
cd quickstart
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
Then, add the theme to the site configuration:
echo 'theme = "ananke"' >> config.toml
4: Add Some Content
hugo new posts/my-first-post.md
5: Start the Hugo server in your localhost then you can see the effect
hugo server -D
6: Customize the Theme
Open up config.toml in a text editor:
baseURL = “https://example.org/" languageCode = “en-us” title = “My New Hugo Site” theme = “ananke” Replace the title above with something more personal. Also, if you already have a domain ready, set the baseURL. Note that this value is not needed when running the local development server.
7: Build static pages
hugo -D
8: deploy to github pages
-
create a new reposity and the name must be the same with your username then combine the
.github.io
so the final url will looks like :https://alexgy1.github.io
-
hugo --theme=ananke --baseUrl="https://alexgy1.github.io" --buildDrafts
-
cd
public
- git init
- git add .
- git commit -m’some messages'
- git remote add origin https://github.com/alexgy1/alexgy1.github.io.git
git remote add origin + url(the url is show in your new created reposity) just copy from github it to here git remote -v too see if added success
- git branch -M main
- git push -u origin main
after doing this you can open the url you just copied from github .visit it then will see the same content form local . done.