Fork me on GitHub
Sweety

  • Home

  • About

  • Tags

  • Categories

  • Archives

  • Schedule

title

Posted on 2019-08-29

hexo+github博客搭建笔记

  • 安装Node.jd

    点击此处访问官网,下载相应的版本

    下载完成后进行安装,选项默认,一直点击next即可
    安装完成后,同时按win键+R键,输入cmd打开页面,再输入

    -v```和```npm -v```,如果出现版本型号,则表示安装成功
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
      
    ![](title/3.png)
    ***
    - ### **安装Git**
    [点击此处](https://git-scm.com/download/win)访问官网,下载相应的版本
    ![](title/2.png)
    (如果下载很慢,可以[点击此处](https://npm.taobao.org/mirrors/git-for-windows/)下载)

    同时按下 Win 键和 R 键打开运行窗口,输入 cmd打开页面,再输入```git --version```,同上,有版本信息表示安装成功
    ***
    - ### **安装hexo**
    选择一个地方新建一个文件夹,用来存放和博客相关的文件(比如我:C:\Blog)

    在该目录下右键点击Git Bash Here,输入```npm install hexo-cli -g```安装hexo,再输入```npm install hexo-deployer-git --save```,安装 hexo 部署到 git page

    然后在刚才新建的文件夹里在新建一个文件夹(比如我:C:\Blog\Hexo)

    在该文件下右键点击Git Bash Here,输入```hexo init```,检测是否安装成功
    以上步骤完成后,打开该文件夹中新建所需要的文件
    ![](title/4.png)
    ***
    - ### **本地查看效果**
    依次输入hexo g(生成静态网页),hexo s(打开本地服务器),然后进入[http://localhost:4000/]该网站查看效果
    ![](title/5.png)
    ***
    - ### **将博客部署到 Github Pages 上**
    现在已经完成本地博客的搭建了,我们只能通过本地连接查看博客,为了让其他人也能查看我们的博客,我们需要将博客部署到Github Pages上

    注册Github账户,(点击此处)[https://github.com/]访问官网,
    ***
    - ### **注册Github账户**
    现在我们本地博客已经搭建完成,接着我们需要把它部署到Github Pages账户上

    首先,[点击此处](https://github.com/)去Github官网注册账户,点击Sign Up注册账户

    再点击 右上角头像旁边的“+”号,点击New repository 开始创建
    ![](title/7.png)

    然后配置 SSH 密钥:配置好 SSH 密钥后, 可以通过 git 操作实现本地代码库与 Github 代码库同步,在第一次新建的文件夹里面(比如我: C:\Blog)点击 Git Bash Here 输入以下命令```ssh-keygen -t rsa -C "your email"```(在引号里输入你的邮箱地址),接下来直接回车就行
    ***
    - ### **在 GitHub 账户中添加你的公钥**
    登录Github,首先点击settings
    ![](title/8.png)
    然后点击SSH and GPG keys,再点击New SSH key,名字随便取

    在第一次新建的文件夹下右键点击Git Bash Here,然后输入```cat ~/.ssh/id_rsa.pub```,复制输出的内容,然后粘贴到刚才公钥的地方
    ![](title/9.png)

    再在Git Bash Here中输入```ssh -git@github.com```,然后出现你的用户名或者在你输入yes后出现用户名就表示成功

    配置Git个人信息,输入如下内容

    $ git config –global user.name “你的用户名”
    $ git config –global user.email “你的邮箱”

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
      公钥配置完成,已经成功连接本机到Github
    ***
    - ### **将本地的 Hexo 文件更新到 Github 的库中**
    登录 Github 打开项目 http:yourname.github.io,点击Clone or download,点击Use SSh,复制地址
    ![](title/11.png)

    打开你第二次创建的文件夹(比如我:C:\Blog\Hexo),右键用记事本等软件打开该文件夹下的 _config.yml 文件
    ![](title/12.png)
    在该文件底部补全如下代码(画横线处为刚才复制的地址):
    ![](title/13.png)
    (注意:所有冒号后面都要空一格)

    然后打开Git Bash Here,执行```hexo g```、```hexo d```或者直接执行```hexo g -d```.如果显示出错,则再次执行```npm install hexo-deployer-git --save```,再执行```hexo g -d

    这时你就可以通过https://你的用户名.github.io访问你的博客了

Hello World

Posted on 2019-08-17

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

John Doe

2 posts
1 tags
RSS
© 2019 John Doe
Powered by Hexo v3.9.0
|
Theme – NexT.Mist v7.3.0