用Hexo免费搞一个Github个人博客

一直都想搞一个“屌屌”的个人博客,今天终于有一个雏形了,搭建方法如下:

网上有一些牛人写的fork方法(但是我不太想在他们下面建分支),所以我就自己查资料搞了起来,这两天一直没搞成功,原来是deploy——>repo配置的参数不对,导致我查了半天报错原因,废话不多说,直接上方法

目录

一、搭建环境准备

 一、创建github账户

 二、下载node.js

 三、下载git安装文件

二、安装Hexo,将Hexo与github page 联系起来

三、写博客、发布文章

四、博客主题推荐

五、添加sitemap和feed插件

六、添加404 页面


 

一、搭建环境准备

github账户,下载node.js,下载git(也可以不下载)

 一、创建github账户

1、Github注册,打开https://github.com/

      

前往自己的邮箱确认注册,这样就真正完成注册啦!

2、创建代码库

登陆之后,点击页面右上角的加号,选择New repository:

    

    

点击 Create repository,创建仓库

3、配置Github Pages

点击右上角setting,下拉

Github将会自动替你创建出一个gh-pages的页面。 如果你的配置没有问题,那么大约15分钟之后,yourname.github.io这个网址就可以正常访问了~ 

如果你找不到Automatic page generator,那么。。。。。。嘿嘿,还有其他办法

哈哈,这样就可以访问啦~ 就问你6不⑥

 二、下载node.js

Windows Installer 32-bit

Windows Installer 64-bit

 三、下载git安装文件

GIt官网下载地址:

Git-2.6.3-64-bit.exe

二、安装Hexo,将Hexo与github page 联系起来

1、下载安装完node之后,打开cmd命令窗口,输入 node -v 

      node çæ¬

2、表示你安装成功啦,命令行窗口索引到安装hexo的文件夹下,输入命令安装hexo:

      

      npm install hexo-cli -g

      

3、初始化博客

      hexo init yourgithubname.github.io (eg:hexo init dreamdameng.github.io)

4、初始化完成进入我们的目录

      cd dreamdameng.github.io

5、安装 

      npm install

6、生成静态页面

      hexo clean

      hexo g   (generate 生成

      hexo s   (server 在服务器运行

7、打开你的浏览器,输入 localhost:4000 。 你的个人网站就这么速度的搭建起来了!

8、Hexo与github page 联系起来

  • 配置git个人信息
  • 配置Deployment

1)设置Git的user name和email:(如果是第一次的话)

git config --global user.name "dameng"
git config --global user.email "dreamdameng@163.com"

2)生成密钥

ssh-keygen -t rsa -C "dreamdameng@163.com"

3)配置ssh

4)安装 hexo-deployer-git

npm install hexo-deployer-git --save

5)在_config.yml文件中,找到deploy,修改为:

   

deploy:
  type: git
  repo: https://github.com/dreamdameng/dreamdameng.github.io.git
  branch: master

三、写博客、发布文章

1、新建一篇博客,执行下面的命令:

     hexo new post "article title"

这时候在我的 电脑的目录下 F:\hexo\source\ _posts 将会看到 article title.md 文件

打开该文件编辑(我是用Uedit打开的)

2、文章编辑好之后,运行生成、部署命令

    hexo g // 生成

    hexo d // 部署

    前两条等同于:hexo d -g  //在部署前先生成

Deploy done : git   //表示运行成功

四、博客主题推荐

知乎答主们推荐的hexo主题大全

1、下载主题

切换到根目录下输入命令:

    cd your-hexo-site

    git clone https://github.com/iissnan/hexo-theme-next themes/next

执行完会自动下载到对应的hexo——>themes目录下面

2、配置主题样式

打开 根目录的_config.yml文件

    theme: next

3、设置好之后,hexo clean 来清除 Hexo 的缓存

    hexo clean

4、验证主题

首先启动 Hexo 本地站点,并开启调试模式(即加上 --debug),整个命令是 hexo s --debug

在服务启动的过程,注意观察命令行输出是否有任何异常信息,如果你碰到问题,这些信息将帮助他人更好的定位错误。 当命令行输出中提示出:

INFO Hexo is running at http://0.0.0.0:4000/. Press Ctrl+C to stop.

此时即可使用浏览器访问 http://localhost:4000 ,检查站点是否正确运行。

当你看到站点的外观与下图所示类似时即说明你已成功安装 NexT 主题。这是 NexT 默认的 Scheme —— Muse

你已经成功安装并启用了 NexT 主题。可以更改一些主题的设定,包括个性化以及集成第三方服务。

5、主题设定

Next主题文件配置

五、添加sitemap和feed插件

切换到你本地的hexo 目录下,在命令行窗口输入以下命令

     npm install hexo-generator-feed -save
     npm install hexo-generator-sitemap -save


修改根目录下_config.yml文件,找到# Extensions增加以下内容

# Extensions
Plugins:
- hexo-generator-feed
- hexo-generator-sitemap
#Feed Atom
feed:
  type: atom
  path: atom.xml
  limit: 20
#sitemap
sitemap:
  path: sitemap.xml

再执行以下命令,部署服务端

hexo d -g

配完之后,就可以访问 https://dreamdameng.github.io/atom.xmlhttps://dreamdameng.github.io/sitemap.xml ,这两个文件已经成功生成了。

六、添加404 页面

直接在根目录下面创建404.tml文件或者404.md文件即可

<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8;"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="robots" content="all" />
  <meta name="robots" content="index,follow"/>
</head>
<body>

<script type="text/javascript" src="https://www.qq.com/404/search_children.js"
        charset="utf-8" homePageUrl="gdutxiaoxu.github.io"
        homePageName="回到我的主页">
</script>

</body>
</html>

特别感谢参考文章:

https://blog.youkuaiyun.com/gdutxiaoxu/article/details/53576018

https://wistbean.github.io/build-personal-website.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值