GitHub个人博客的搭建

个人搭建GitHub的过程,总的感觉是,众里千百度,蓦然回首,我在做什么,我做了什么,我还要做什么,其次好好

好好学英语                                                                                                                                                                                   

首先

     下载       git

 https://www.git-scm.com/download/

     下载      node.js

https://nodejs.org/en/                              (建议下载带有  LTS)

开始GitHub的征途

以下操作在新建的文件夹里,打开 Git Bash Here(鼠标右键) 

   1. 开始个人的信息

       $ git config --global user.name "GitHub的用户名"            //要有 " "
       $ git config --global user.email "GitHub的注册邮箱"
       $ ssh-keygen -t rsa -C "注册邮箱"                       // 大写的“C”
       $ cd ~/.ssh 
       $ ls                                                   //  出现 _id_rsa.pub的文件
       $ pwd                                                  //  找到文件的位置


    2 . ssh密钥


       复制 id_rsa.pub 内容
       打开GitHub的setting中的SSH and GPG keys 

          点击New SSH key       粘贴到Key上(记得给Title起个名字呀)

      完成后测试:

       $  ssh -T [email protected]    

      选择yes

       $  cd -                     //   切换到上一次的目录


    3 . 安装hexo

      $ npm install -g hexo-cli         // 安装hexo,前提已经在hexo官网下载
      $ hexo install                              //安装运行hexo的一些必要的组件
      $ npm install hexo-deployer-git --sava  
        
      $ hexo init                       // 初始化
      $ hexo s                          // 启动本地服务器

  出现 http://localhost:4000            搜索即可               

 上述步骤为搭建博客,以上只是野花一朵,要走的路还有很远

 
    4 .   书写内容 

这才重点,不写内容,难道闲得慌?  

若要上传个人书写的内容          (前提你需要知道如何书写 扩展名为  .md  的文件)        (学无止境呀!!!)

       $ hexo new   文件名(无扩展名)         //文件位于初建文件夹里source下的_posts里
                                                打开新建文件,书写内容   
              
                                 
       $ hexo g                                // 生成网页
       $ hexo s                                // 开启服务

出现 http://localhost:4000           搜索即可


      5 . 修改 _config.yml


  将网站部署到服务器上 使Hexo与GitHub关联

        打开文件夹里的  _config.yml
        修改为 :

        type: git                                                 // 有空格
        repo: [email protected]:JSL22/JSL22.github.io.git            //有空格
        branch: master                                            //有空格
复制自己的    repo
         $ hexo d                     // 将网站部署到服务器上

     还可以在此文件里改自己喜欢的主题,可以自行百度

  


遇到问题

(1).

 $ hexo d  
 ERROR Deployer not found: git

  解决 :

$ npm install --save hexo-deployer-git

(2)

      若是端口被占可以

          $ hexo g -d 5000                //修改端口号为5000 

     但还错,嘿嘿!自行解决 !

(3)

$ git status
fatal: not a git repository (or any of the parent directories): .git

解决 :

$ git init
发布了41 篇原创文章 · 获赞 12 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_42259578/article/details/88363702