Github Pages Personal Blog Source Files#
1. Background#
-
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.
-
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#
- Backup of source files;
- Portability of the blog.
3. Points to Note#
-
Delete the
.git
file in the cloned theme files under thethemes
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#
-
Clone the repository to your local machine;
-
Install Node.js and Git; Official Chinese Documentation
-
Install Hexo;
$ npm install -g hexo-cli
-
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"
-
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.
-
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