Build the hexo blog and deploy it on github to build the hexo blog github
I have been thinking about how to build my own blog over the past few days. Accidental access to hexo
Hexo is a fast, simple, and powerful blog framework driven by Node. js. It supports multithreading and generates hundreds of articles in just a few seconds. Supports markdown to write articles, allowing you to easily generate static Web pages hosted on github.
It feels good.
Front-end staff are sharing their code with github. So I want to use hexo to deploy it on git. Create your own blog.
1. Install hexo
Before installing hexo:
Install Git
Download msysgit and execute it to complete the installation.
Install node. js
It is very easy to install Node. js in a Windows environment. You only need to download the installation file and execute it to complete the installation.
Install hexo:
Use the npm command to install the SDK. (Right-click anywhere and select Git bash)
npm install -g hexo
Create an hexo Folder:
After the installation is completeH:\hexo
), Execute the following commands (inH:\hexo
Right-click inside and select Git bash), Hexo will automatically create all the files required for the website in the target folder.
hexo init
Install dependency packages
npm install
Start local services
Now we have set up a local hexo blog and run the following command:H:\hexo
), And then enter it in the browser.localhost:4000
Look.
hexo generatehexo server
Now, the local blog has been set up, but it is local. No one else can see it,
Next we will deploy the blog on github.
Register a Github account.
Skip if it already exists.
You don't need to introduce it here.
Create repository
After logging on to github, click "+" in the upper right corner of github, select "New repository" from the drop-down menu, and enter the library name on the following page, check "Initialize this repository with a README" and click "create repository" to create a database.
Deployment
Edit_config.yml
(InH:\hexo
). During deploymentzippera
Change to your account name.
deploy: type: github repository: https://github.com/xiaomiya/xiaomiya.github.com.git branch: master
Run the following commands to complete the deployment.
hexo generatehexo deploy
Note: Some new users need to set up ssh; otherwise, the above command will fail. For the introduction and Setup of ssh, please refer to the official tutorial. Don't worry, it's very simple.
Remember: every time you modify a local filehexo generate
To save. Every time you use a commandH:\hexo
Directory.
Okay, our blog has been fully built and accessed in a browserzippera.github.io
You can see your achievements!
Another point is that some users have this prompt after hexo deploy.
Enter the email address we have verified on git.
Such as this. Again hexo deploy
It is released.
We can see that we have achieved success...
Bugs
- Some netizens do not reply to the shortcut menu
git bash
Option, which can be found in the Start Menugit bash
And thencd
Go to the corresponding directory to execute the command.
- After the deployment of github is complete, the 404 error may occur immediately. This is normal. (a maximum of 10 minutes can be accessed. If not, it is likely that the verification email sent to you by github has not been opened. According to multiple parties, it will be okay after verification.
- If
hexo d
Laterfatal: 'username.github.io' does not appear to be a git repository
First, check whether the repo name complies with the specifications, whether it contains uppercase letters, and whether the deploy configuration in config. yml is correct. Second, disable git bash, re-open it, and execute the command.
- Some may not be in the IT industry, or may not know much about shell commands. When a password is required, the password is not displayed for security purposes, not for your failure.
- Do not use notepad in windows to open and edit files. sublime text is recommended, which is very simple. If you have already edited it in notepad, use sublime text to transcode it to utf8 」.
- When installing hexo, it is possible that the network is not powerful and the global break wall is good.
- If you have any other problems, delete. deploy and db. json and generate a new one.
Tips
Hexo now supports simpler command formats, such:
hexo g
=hexo generate
hexo d
=hexo deploy
hexo s
=hexo server
hexo n
=hexo new
How to write a blog on octopress github?
This article is successfully tested in Windows 7.
Install and set Git
Download Git
For Windows, use the default installation. After installation, you can use Git locally.
To put the content on Github, you must first register an account on the Github website, and then create an SSH Key using Git on the local machine. The procedure is as follows:
Run the following command on Git Bash:
Ssh-keygen-C "username@email.com"-t rsa
Note: The username@email.com needs to be replaced with the Email address or Username you registered on Github
This will generate a. ssh folder under the user directory (C: \ Users \ User Name), which contains the corresponding SSH
Keys, where id_rsa.pub is the SSH public key file required by Github.
Go to the c: \ Users \ User Name \. ssh \ directory and find id_rsa.pub (the location may not be correct, but make sure it is a file ending with. pub). Open and copy all the content in notepad.
Note: It is recommended that the name of the private key should be "id_rsa", so that this file will be found when you connect to Github. If the file name is set, you can rename the file later.
On the github website, choose "Account Settings"> "SSH Public Keys"> "Add another ".
Public key, paste the copied content into the key text box.
In this way, you can directly use Git and GitHub.
Note: It is recommended to enter "ssh-v git@github.com" in Git Bash to test normal connection to github
Install the Ruby Environment
Download RubyInstaller and DevKit.
.
Install RubyInstaller first, and decompress DevKit (the path cannot contain Chinese characters ).
In the "Start Command Prompt with Ruby" Command line, enter the DevKit decompression directory, and then run the following Command:
Ruby dk. rb init
Ruby dk. rb install
Gem install rdiscount -- platform = ruby
If the installation is successful, you can use some Ruby tools and provide a basic environment for building a blog later.
Install Octopress
First clone an Octopress file from Github through Git (enter the command on Git Bash)
Git clone git: // github.com/imathis/octopress.git octopress
Then install some dependent tools (entered in Start Command Prompt with Ruby later)
Cd octopress
Ruby -- version # shocould report Ruby 1.9.2
Gem install bundler
Bundle install
Install Octopress's default Theme
Rake install
Configure Octopress
Change the _ config. yml encoding in the octopress folder to the UTF-8:
Select the encoding format as UTF-8 when saving (or saving)
Modify _ config. yml to correct url, title, subtitle, autho ...... the remaining full text >>>
How can I help myself after GitHub is unavailable in China?
It is damaged. Both the offline git server and the recommended git server are uncomfortable. Can I build github by myself? Or are there any alternatives available? The wall is not stable. For technical discussion only, try not to discuss other topics. 「 Github confirmed that it has been unblocked yesterday. Most of the DNS in each province in China has been updated. After testing, access to github is normal, and the IP address resolved by DNS is already the correct IP address .」