Mac build github Page of Hexo free personal blog

1. Basic preparation

  1. github account
  2. Install git
  3. Install node.js, npm

2. Create repo

3. Configure SSH key

This step is not important, configure SSH key or not, does not affect the construction and use of the blog, just after the configuration, update the blog a little convenient, do not always lose your username and password.

  • Open the terminal, enter the following command
cd .ssh
ls -la

Whether there has been or id_dsa.pub id_rsa.pub file list check terminal output, if the file already exists, then you can skip steps

  • Creating SSH key
    $ ssh-keygen -t rsa -C "[email protected]"
    Note: Here github account registered mail mailbox
    Enter, then you will be prompted to allow you to enter a file name, hit enter will create a file using the default filename (recommended to use the default file name);
    then will prompt you to enter the password twice (no feedback after entering the password, the display is still blank, but you really have entered), of course, the password can not lose, hit enter, if there is no password, after submitting blog updates when not You need to enter a password.
  • Add SSH key to github
    after the second step, if you do not specify a file name (that is, using the default file name), then under your .ssh folder, there should be a id_rsa.pub file, open the file, copy the inside text.
    Then landing github, click the triangle icon in the upper right corner of the picture on the right, click Settings, then click on the left menu bar SSH and GPG keys, click on the new ssh key, title free to fill in, fill in the content of your copy of the key column, click add ssh key , you can add a ssh key up.
  • Verify that SSH key configuration is successful
    terminal and type:
    ssh -T [email protected]
    Enter, you will see the following reply, that your ssh key to add a success.
    Hi chenglaiyong! You've successfully authenticated, but GitHub does not provide shell access.
    If the process prompts you perimission deny-related errors, in command with sudo and then execute commands when entering your password appleid should be on it. sudo-to-run with administrator privileges.

4. Installation Hexo

  • Input Terminal:
    npm install -g hexo
  • Initialization resources required to create
    the new name of the file to any folder, cd into the folder, run the following command
hexo init
npm install
  • Generate and publish
hexo g  // 全拼是:hexo generate,可以简写成 hexo g
hexo s  // 全拼是:hexo server,可以简写成 hexo s

This will open a local blog server, open the browser, type in the address bar HTTP: // localhost: 4000 , you can view the local blog, hexo default generates a hello world blog.
Note: The above beginning hexo command execution directory must be blog directory file folder you created, because only have to create and publish all resources hexo in that folder.

5. Sync Hexo to Github

  • installation
    npm install hexo-deployer-git --save
  • Open _config.yml local blog directory file, edit them deploy node
deploy:
type: git
repository: https://github.com/chenglaiyong/chenglaiyong.github.io.git branch: master 

Note: ":" followed by a space, which is a pit
repository address can be obtained from the following figure

url.jpeg

Save it
, of course you can use SSH address as the repository address, click on the upper right corner of Use SSH, after the same operation.

  • Generation and distribution
hexo clean  // clean本地项目,防止缓存
hexo g      // 根据你编辑的md格式的博客,生成静态网页
hexo d      // 将本地博客发布到github

Then, in the browser address bar enter yourusername.github.io can access your blog, others can also access your blog via this address.

6.Hexo commonly used command line

hexo init      //在指定目录执行该命令,会将当前目录初始化为hexo站点,生成hexo站点所需的一切文件
hexo new “my new blog title”  //新建一篇文章。如果没有设置 layout 的话,默认使用 _config.yml 中的 default_layout 参数代替。如果标题包含空格的话,请使用引号括起来。
hexo clean      // 清除缓存,如果对本地文件做了修改,同步到远程验证修改的效果之前,先clean,清除缓存
hexo generate  // 可以简写成hexo g 根据markdown文件生成静态文件
hexo server    // 或者简写成hexo s 启动本地hexo 服务器,默认localhost:4000可以访问
hexo deploy    // 或者简写成hexo d 将本地修改,部署到远端
hexo version    // 显示hexo版本

7. Other common actions

  • New blog
    hexo new "the title of your blog"
    suggest learning  writing | Hexo
  • Bowen Delete
    to delete the automatically generated hello world
    find / source / _posts folder, which put all of our writing blog, which articles you want to delete, delete here directly, and then re-posted to github, this blog disappeared
  • Bowen added to tag and classify
    new blog document is created, then open the top there will be a automatically generated text, added tag and category in which you can specify the tag and label classification.
  1. Edit _config.yml
    post_asset_folder: to true
    so hexo created at the source article directory each time you use hexo new title command of the same name folder to store resources.
  2. achieve
 
photo.jpeg

markdown referenced like this:

{% asset_img newRepository.png 创建repository%}

asset_img said to be a reference picture, newRepository.png title, the latter is prompted suspension of the title and picture shows.

8. Installation Theme

  1. Terminal cd to the folder where the hexo execute the following command:
    git clone https://github.com/iissnan/hexo-theme-next themes/next
  2. The next hexo _config.yml directory name in the theme of landscape modification is next, redeploy it.
  3. fork me on github
    if you visit my personal blog, you will find the top right corner there is a sloping fork me on github icon, want to integrate this icon, go here to pick your favorite style, copied the style code.
    Themes in the local blog directory / next / layout / layout.swig file, and then paste the code you copied the style to the following location.
  1. You can choose a different theme Themes | HEXO , as above.

Guess you like

Origin www.cnblogs.com/chenglaiyong/p/11581064.html