GitHub is a global open code hosting platform that provides developers with a convenient platform for collaboration and code sharing. Hexo is a fast, simple and efficient blogging framework developed based on Node.js. In this article, we will explore how to set up a Hexo blog on GitHub.
npm install -g hexo-cli
hexo init myblog cd myblog npm install
This command will create a myblog folder in the current directory and install Hexo in it.
npm install hexo-deployer-git --save
This command will install the hexo-deployer-git plug-in to our blog. Then, add the following configuration in the _config.yml file:
deploy: type: git repository: git@github.com:username/username.github.io.git branch: master
where username is our GitHub username. Then, run the following command to deploy the blog to GitHub Pages.
hexo clean && hexo g && hexo d
Hexo will automatically push the blog files to our GitHub Pages page, and we can view our blog by visiting https://username.github.io.
hexo new post "文章名称"
This command will create a new Markdown file in the source/_posts directory, where the "article name" is the The title of the published article.
After running the above command, modify the *.md file under source/_posts/ and write your own article content.
git clone https://github.com/author/author.github.io.git themes/theme-name
where author is the GitHub username of the theme author and theme-name is the name of the theme.
Then, in the root directory of Hexo, open the _config.yml file and modify theme to the name of the theme you installed. For example:
theme: theme-name
In this way, you have set up your own Hexo blog, and you can write and share happily.
The above is the detailed content of Discuss how to build a Hexo blog on GitHub. For more information, please follow other related articles on the PHP Chinese website!