mycpen

Mycpen

记录学习历程与受益知识
github
telegram
bilibili

03_Hexo-Github Pages personal blog source file backup migration

Github Pages Personal Blog Source Files#

1. Background#

  1. Source file storage issue: The personal blog built with Hexo only saves the HTML static files generated after publishing with Hexo, while the source Markdown files, theme configurations, and other resources are still stored locally.

  2. Source file privacy: Considering the confidentiality of the source files, creating a new branch to store the source files was abandoned, and a new project was created instead.

2. Purpose#

  1. Backup of source files;
  2. Portability of the blog.

3. Points to Note#

  • Delete the .git file in the cloned theme files under the themes directory;

  • In node-modules/, some custom configurations have been made and changes have been made to the source code, which need to be synchronized. Do not include them in the .gitignore file;

    The .gitignore configuration is as follows:

.DS_Store
db.json
*.log
public/
.deploy*/

4. Configuration Steps#

  1. Clone the repository to your local machine;

  2. Install Node.js and Git; Official Chinese Documentation

  3. Install Hexo;

    $ npm install -g hexo-cli
    
  4. If Git information has not been configured before, it needs to be configured;

      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"
    

    image-20220830155020917

  5. Execute Hexo commands to generate static files, deploy the website, etc. For example:

    hexo clean ; hexo g ; hexo d ; hexo s
    

    The process goes smoothly.

    image-20220830155418809

  6. Commit the local source file changes.

    git pull ; git add . ; git commit -m 'backup' ; git push
    

    Command combination: git pull ; hexo clean ; hexo g ; hexo d ; git add . ; git commit -m 'backup' ; git push

5. Reference Articles#

Relationship between Hexo and Blog Source Files

Official Documentation Branch Example: gh-pages

Example of Creating a New Repository 1

Example of Creating a New Repository 2

Example of Creating a New Repository 3

Example of Creating a New Branch 1

Example of Creating a New Branch 2


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.