Set up a personal blog, you can organize and publish what you have learned every day, or you can use it as your own review, learn quickly!

1. Set up a locally accessible blog

First, the blog will now be built locally using Hexo, as shown in the steps on the official website.

  • Download related tools

  • site

Once set up, execute hexo Server to start the project and access it from the local IP address.

IP address: http://localhost:4000/

2. Push to Github Pages

Once locally accessible, we need to publish the current blog on Github Pages, and everyone can access the blog using your Github username.github. The following is an example:

wuqingc.github.io/

Specific steps:

  1. Create a new repository. Your repository should be named < your GitHub username >.github.

  2. Create a new source branch on the repository page as a push branch for local blog changes.

    This is important because Github Pages only recognizes page files that are in the Master branch, so you need to push the source code to another branch.

    The compiled page file can then be placed in the master.

  3. Push your Hexo site folder into repository.

  4. Go to GitHub’s Applications Settings and configure Travis CI permission to access your Repository.

  5. You should be redirected to Travis CI’s page. If no, go to it manually.

  6. Create a new TAB in your browser, go to GitHub and create a New Personal Access Token, just check the repo permissions and generate a new Token. After the Token is generated, copy and save it.

  7. Go back to Travis CI, head to your Repository Settings page, and create a new Environment variable under Environment Variables with Name GH_TOKEN and Value the Token you just generated on GitHub. Make sure DISPLAY VALUE IN BUILD LOG is left unchecked to avoid your Token leakage. Click Add to save.

  8. Create a new.travis. Yml file in your Hexo site folder:

sudo: false
language: node_js
node_js:
  - 10 # use nodejs v10 LTS
cache: npm
branches:
  only:
    - source # build master branch only
script:
  - hexo generate # generate static files
deploy:
  provider: pages
  skip-cleanup: true
  github-token: $GH_TOKEN
  keep-history: true
  on:
    branch: source
  target_branch: master
  local-dir: public
Copy the code

Push.travis. Yml into repository. The Travis CI should start automatically and push the generated files to the Master branch of the same Repository.

After that, every change to the Source branch will be monitored by the Travis CI and automatically compiled and pushed to the Master branch.

Site visit

Once you’re done, you can access your blog site at https:// your username.github. IO /, and put on a nice outfit for your blog.

Theme Settings

After you find your favorite theme on Github, follow the steps to change the theme for your blog.

  • Hexo website custom theme
  • Next concise theme — the one I’m currently using
  • Next help documentation

Error collecting

During deployment, the modified file failed to pass the Travis CI compilation and encountered the following error:

The command "eval npm ci  " failed. Retrying, 3 of 3.
Copy the code

Solution:

Delete package-lock.json from the project root directory and add it to.gitnore without pushing it to Github.