zoukankan      html  css  js  c++  java
  • Hexo和github搭建个人博客

    • GitHub账号
    • mac/pc

    环境

    1
    2
    node.js
    git

    创建GitHub仓库

    登陆GitHub,创建一个新的Respository

    Repository name叫做{username}.github.io

    {username}代表你的GitHub用户名,Repository name一点要叫这个

    绑定域名

    待定

    绑定ssh秘钥

    • 设置git用户名和邮箱
    1
    2
    git config --global user.name "liuxianan"
    git config --global user.email "xxx@qq.com"// 填写你的github注册邮箱
    • 生成ssh秘钥
    1
    ssh-keygen -t rsa -C "邮件地址"

    连续3次回车,不需要输入密码

    公钥文件在在用户目录下.sshid_rsa.pub

    • 进入github -> settings -> SSH and GPG keys,点击new SSH key,将id_rsa.pub中的内容复制到其中,并确定,这样只要使用生成秘钥的电脑git访问GitHub是都不需要再输入用户名密码

    安装Hexo

    Hexo本体和部署插件

    1
    2
    npm install -g hexo
    npm install hexo-deployer-git --save

    博客初始化

    进入选的的文件夹

    1
    hexo init

    此时会生成blog文件夹,这就是hexo默认的博客

    1
    2
    3
    cd blog
    hexo g # 生成
    hexo s # 启动服务

    此时可以本地启动博客,去浏览器打开网址即可,默认是localhost:4000

    可以看到一篇Hello World的文章

    默认主题很简洁,想要更喜欢的主题可以去官网寻找https://hexo.io/themes/

    主题选择

    本次博主选择主题https://www.huweihuang.com/

    GitHub地址https://github.com/huweihuang/hexo-theme-huweihuang

    • init
    1
    2
    3
    git clone https://github.com/huweihuang/hexo-theme-huweihuang.git ./hexo-huweihuang
    cd hexo-huweihuang
    npm install
    • 编辑配置文件

    hexo-huweihuang/_config.yml

    根据自己的喜好修改配置文件

    以下配置仅针对该主题博客,其他的主题配置可能有所不同!

    1
    2
    3
    4
    # Site
    title: {标题}
    subtitle: {副标题}
    author: {作者名字}
    1
    2
    3
    # 下面的配置注释掉,是绑定域名的相关配置,以后也可以改成自己的域名
    url: http://www.huweihuang.com/
    root: /
    1
    2
    3
    # Site settings,在页面底部,酌情填写
    SEOTitle: {作者名} | Blog
    email: {邮箱}
    1
    2
    # 填写你的GitHub用户名
    github_username: {username}
    大专栏  Hexo和github搭建个人博客 - 朱晨lass="highlight js">
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    # 以下为默认内容,可以先注释掉,也可以改成自己的相关网址
    # 最外层的`friends:[]`不能注掉
    friends: [
    {
    title: "CSDN Blog 胡伟煌",
    href: "http://blog.csdn.net/huwh_"
    },
    {
    title: "DockOne 胡伟煌",
    href: "http://dockone.io/people/胡伟煌"
    },
    {
    title: "阿里云栖社区 胡伟煌",
    href: "https://yq.aliyun.com/u/huweihuang"
    }
    ]
    1
    2
    3
    4
    5
    6
    7
    # github仓库的ssh地址,{username}代表你的github用户名
    # {msg}代表你对每次部署的描述内容,相当于git commit -m 后面加的描述内容,可以不填
    deploy:
    type: git
    repository: git@github.com:{username}/{username}.github.io.git
    branch: master
    message: {msg}
    • 本地预览
    1
    2
    3
    cd hexo-huweihuang
    hexo g
    hexo s

    打开localhost:4000,可进行预览

    评论功能

    待定

    编写markdown博客

    新建markdown文件

    开头如下,以下是本篇博客的例子

    tags是标签,可自行添加

    top填1表示置顶,0表示不置顶

    标题和时间可自行修改

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ---
    title: "Hexo和github搭建个人博客"
    catalog: true
    toc_nav_num: true
    date: 2019-07-06 10:51:24
    subtitle: "你的博客你做主"
    header-img: "/img/article_header/article_header.png"
    tags:
    - Hexo
    - Github
    catagories:
    - Hexo
    updateDate: 2019-07-06 22:26:24
    top: 0
    ---

    接下来就可以编写正文了…

    markdown文件要放在hexo-huweihuang/source/_posts文件夹中

    部署博客

    1
    2
    3
    cd hexo-huweihuang
    hexo g
    hexo d # deploy部署

    也可使用hexo g -d或者hexod -g

    如果有些奇怪的问题可以hexo clean清除已经生成的部署文件,再重新执行

    结束

    访问{username}.github.io即可访问你的私人博客

    如果绑定域名也可通过域名访问





  • 相关阅读:
    二叉树的递归遍历 The Falling Leaves UVa 699
    二叉树的递归遍历 天平UVa839
    二叉树的递归遍历 Tree UVa548
    通过缓冲传递数据-结构体
    fread读取文件(二进制文件)
    socket编程--相关函数--sendto();read();
    socket 编程--sockaddr与sockaddr_in区别与联系(转)
    百度Apollo 尝试
    检测服务器端口是否被占用
    qt5的.ui文件在VS2010中无法编译问题
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12227154.html
Copyright © 2011-2022 走看看