zoukankan      html  css  js  c++  java
  • 使用github和hexo搭建博客


    title: How to build your blog by Hexo in github

    Welcome to huihuang's blog,you will find what you expectd

    环境准备(win7_64环境)

    安装git

    Go to git_download More info: The version of git is 2.10.2

    安装node.js

    Go to nodejs_download

    More info: The version of nodejs is 0.10.33

    配置Github

    建立与你用户名对应的仓库,仓库名必须为【yourusername.github.io】

    More_info: you can view the:blog

    安装Hexo

    打开Git命令行,执行如下命令

    bash $ npm install -g hexo

    在电脑中建立一个名字叫「Hexo」的文件夹(比如我建在了D:Hexo),然后在此文件夹中右键打开Git Bash。执行下面的命令

    $ hexo init

    [info] Copying data

    [info] You are almost done! Don't forget to run npm install before you start b logging with Hexo!

    Hexo随后会自动在目标文件夹建立网站所需要的文件。然后按照提示,运行 npm install(在 /D/Hexo下)

    npm install

    会在D:Hexo目录中安装 node_modules。

    启动服务

    运行下面的命令(在 /D/Hexo下)

    $ hexo server

    [info] Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

    创建新的post

    新打开一个git bash命令行窗口,cd到/D/Hexo下,执行下面的命令

    $ hexo new "My New Post"

    [info] File created at d:Hexosource_postsMy-New-Post.md

    刷新http://localhost:4000/,可以发现已生成了一篇新文章 "My New Post"。

    生成静态页面

    $ hexo generate

    编辑文章

    hexo new "My New Post"会在D:Hexosource_posts目录下生成一个markdown文件:My-New-Post.md

    可以使用一个支持markdown语法的编辑器(比如 Sublime Text 2)来编辑该文件。

    部署到github

    部署到Github前需要配置_config.yml文件,首先找到下面的内容

    #Deployment
    
    ##Docs: http://hexo.io/docs/deployment.html
    
    deploy:
    
      type:
    

    然后把它们修改为

    #Deployment
    
    ##Docs: http://hexo.io/docs/deployment.html
    
    deploy:
    
     type: github
    
     repository: git@github.com:zhchnchn/zhchnchn.github.io.git
    
     branch: master
    

    Notice

    Repository:必须是SSH形式的url(git@github.com:parktrick/parktrick.github.io.git),而不能是HTTPS形式的url(https://github.com/parktrick/parktrick.github.io.git),否则会出现错误:
    

    测试

    当部署完成后,在浏览器中打开https://parktrick/github.io正常显示网页,表明部署成功。

    总结部署

    hexo
    
    hexo generate #生成
    
    hexo deploy 
    

    常用命令

    hexo new "postName" #新建文章
    
    hexo new page "pageName" #新建页面
    
    hexo generate #生成静态页面至public目录
    
    hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
    
    hexo deploy #将.deploy目录部署到GitHub
    
    hexo help  # 查看帮助
    
    hexo version  #查看Hexo的版本
    

    复合命令

    hexo deploy -g  #生成加部署
    
    hexo server -g  #生成加预览
    

    命令简写

    hexo n == hexo new
    
    hexo g == hexo generate
    
    hexo s == hexo server
    
    hexo d == hexo deploy



  • 相关阅读:
    文本溢出隐藏与定位
    css基本属性 内边距 外边距及盒模型
    CSS基本属性2
    CSS基本属性
    CSS入门
    表格与表单
    列表与图片
    html标签类型
    HashMap和HashTable
    Map接口
  • 原文地址:https://www.cnblogs.com/uglyliu/p/6121764.html
Copyright © 2011-2022 走看看