美文网首页HEXO
Hexo部署到GitHub上

Hexo部署到GitHub上

作者: spicychocolate | 来源:发表于2017-03-28 20:23 被阅读16次

    tips: 部署前首先得有一个Github账号

    第一步:新建一个仓库

    仓库名:<code>your_user_name.github.io</code>,例如,我的用户名是spicychocolate,那么新建的仓库名为<code>spicychocolate.github.io</code>


    Paste_Image.png

    注意:因为我已经创建了这样一个仓库,所以提示已经存在该仓库名


    Paste_Image.png
    点击Create Repository,创建成功后如下图所示。
    Paste_Image.png

    第二步: 安装git插件

    切换至项目根目录,执行以下代码:

    npm install hexo-deployer-git --save
    

    第三步:修改根目录配置文件<code>_config.yml</code>

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

    第四步:生成静态文件、部署到github

    切换至项目根目录,执行以下代码:

    hexo generate 
    

    生成静态文件

    hexo deploy
    

    将项目部署到github上,可在新建的仓库查看上传的文件,第一次部署,会在执行过程中让输入github的账号及密码。
    最后,部署成功后,可通过<code>your_user_name.github.io</code>访问博客。比如,我的博客地址:spicychocolate.github.io

    相关文章

      网友评论

        本文标题:Hexo部署到GitHub上

        本文链接:https://www.haomeiwen.com/subject/ujrsottx.html