Github 搭建个人博客
转自 :http://hifor.net/2015/07/01/零基础免费搭建个人博客-hexo-github/
使用hexo生成静态博客并架设在免费的github page平台
准备#
系统:
* Window 7 64位
使用软件:
* Git v1.9.5
[下载地址] 百度云 360云盘 访问密码 d269 Git官网
* Node.js v0.12.5 x64
[下载地址] 百度云 360云盘 访问密码 608f node.js官网
32位或64位按自己电脑的系统来选择,如果不清楚,可以直接在官网下载32位的,可以兼容64位系统
备注:
不同软件版本的安装与使用会有差异,请尽量与本教程保持一致
安装Git#
安装Node.js#
验证软件正确安装#
- 同时按下Win键和R键(或者点击“开始菜单”->点击“运行”),打开运行窗口,输入“cmd”
然后输入以下命令,结果与下图相同则说明安装正确,若不正确可以卸载软件重新安装
git --version
node -v
npm -v
- 1
- 2
- 3
申请GitHub#
- 点击->GitHub进入官网注册帐号
- 按下图分别输入用户名、邮箱、密码,然后点击注册
- 按默认点击“Finish sign up”
- 点击”New repository”,新建一个版本库
- 输入Repository name:yourname.github.io(yourname与你的注册用户名一致,这个就是你博客的域名了)
到此github帐号申请完成 - 启用GitHub Page
点击右边的“Setting”菜单进入设置,点击”Launch automatic page generator”
点击底部的”Continue to layouts”
最后点击”Publish page”,发布github默认生成的一个静态站点 - 验证邮箱
点击个人设置
点击”Send verification Email”发送验证邮件
进入你的邮箱,查收验证邮件进行验证
安装Hexo#
hexo是基于node.js的静态博客,官网也是搭建在GitHub上
* 在电脑上新建一个blog文件夹,该文件夹用于存放你的博客文件,然后右键单击选择“Git Bash”
* 大家估计都有被“墙”的经历,安装hexo为了避免出现类似情况,我使用淘宝NPM镜像,输入以下命令等待安装完成
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
- 1
$ cnpm install -g hexo-cli
- 1
与原先的npm完全一样,只是命令改为cnpm,一样等待hexo安装完成
出现的WARN可以不用理会
继续输入以下命令
$ cnpm install hexo --save
- 1
安装完成后,在输入命令,验证是否安装正确
$ hexo -v
- 1
本地运行hexo#
- 初始化hexo
$ hexo init
- 1
$ cnpm install
- 1
$ hexo s -g
- 1
打开浏览器,输入localhost:4000,就可以在本地看到你的个人博客了
* 停止运行
按住Ctrl+C键即可停止
管理博客#
- 配置信息
使用Sublime_Text编辑器(绿色软件无需安装,解压即可使用)打开blog/_config.yml文件,进行配置
#博客名称
title: 我的博客
#副标题
subtitle: 一天进步一点
#简介
description: 记录生活点滴
#博客作者
author: John Doe
#博客语言
language: zh-CN
#时区
timezone:
#博客地址,与申请的GitHub一致
url: http://elfwalk.github.io
root: /
#博客链接格式
permalink: :year/:month/:day/:title/
permalink_defaults:
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: true
tab_replace:
default_category: uncategorized
category_map:
tag_map:
#日期格式
date_format: YYYY-MM-DD
time_format: HH:mm:ss
#分页,每页文章数量
per_page: 10
pagination_dir: page
#博客主题
theme: landscape
#发布设置
deploy:
type: git
#elfwalk改为你的github用户名
repository: https://github.com/elfwalk/elfwalk.github.io.git
branch: master
- 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
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 写一篇文章
输入创建文章命令,生成一个md文件(/blog/source/_posts/)
$ hexo new "hello"
- 1
title: hello
date: 2015-07-01 22:37:23
categories:
- 日志
- 二级目录
tags:
- hello
---
摘要:
<!--more-->
正文:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
发布博客#
- 设置git身份信息
$ git config --global user.name "你的用户名"
$ git config --global user.email "你的邮箱"
- 1
- 2
$ cnpm install hexo-deployer-git --save
- 1
$ hexo d -g
- 1
发布时需要输入github的帐号和密码,输入密码时是看不到自己输入的内容的
发布成功后,访问yourname.github.io看下成果
作者: LandWind
出处:https://www.cnblogs.com/LandWind/articles/8195861.html
版权:本文采用「署名-非商业性使用-相同方式共享 4.0 国际」知识共享许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下