github搭建个人博客

HUGO+github搭建博客

  • hugo
    • 搭建
    • github 多账户使用ssh
      • 启动ssh代理
      • 添加config配置文件分别映射不同的GitHub账户
      • 项目配置
      • 测试配置是否成功
      • hugo生成网页

hugo

安装环境:win7+git+hugo_0.53
百度云盘下载:https://pan.baidu.com/s/1VnvIjkMLxndXGclACry63w 提取码:5d49
环境变量设置hugo安装路径

搭建

使用GitBash打开工作路径比如:workspace/blog
hugo new site .
生成如下目录:
archetypes/
content/ 文章
layouts/ head.html footer.html 模板
static/ js和css
config.toml
也可以下载本人博客
git clone https://github.com/wugjun/wugjun.github.io.git

hugo server 启动服务,访问主页http://localhost:1313

github 多账户使用ssh

ssh-keygen -t rsa -C "[email protected]" -f ~/.ssh/id_rsa_wugjun

ssh-keygen -t rsa -C "[email protected]" -f ~/.ssh/id_rsa_drsin

启动ssh代理

eval ssh-agent -s

添加config配置文件分别映射不同的GitHub账户

进入~/.ssh目录,新建config文件,并添加相应的内容:

# drsin GitHub
Host github.com
HostName github.com
PreferredAuthentications publickey
# 指定特定的ssh私钥文件
IdentityFile ~/.ssh/id_rsa_drsin

# wugjun GitHub  别名
Host wugjun 
HostName github.com
PreferredAuthentications publickey
# 指定特定的ssh私钥文件
IdentityFile ~/.ssh/id_rsa_wugjun

项目配置

git config user.name wugjun

git config user.email [email protected]

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = git@wugjun:wugjun/blog.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[gui]
        wmstate = zoomed
        geometry = 841x483+25+25 189 218
[user]
        name = wugjun
        email = [email protected] 

测试配置是否成功

ssh -T [email protected]

hugo生成网页

hugo

当前目录下生成public文件,进入public 目录,git init初始化 。

cd .git

vi config

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = git@wugjun:wugjun/wugjun.github.io.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[gui]
        wmstate = zoomed
        geometry = 841x483+25+25 189 218
[user]
        name = wugjun
        email = [email protected] 

git commit -am "msg"

博客主页

你可能感兴趣的:(hugo)