惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
V
Visual Studio Blog
C
Check Point Blog
博客园 - 聂微东
博客园 - 叶小钗
Microsoft Security Blog
Microsoft Security Blog
E
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
C
Comments on: Blog
N
News and Events Feed by Topic
L
Lohrmann on Cybersecurity
小众软件
小众软件
H
Heimdal Security Blog
云风的 BLOG
云风的 BLOG
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
Security Latest
Security Latest
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
H
Hacker News: Front Page
D
Docker
N
News and Events Feed by Topic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy & Cybersecurity Law Blog
S
Schneier on Security
T
Troy Hunt's Blog
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
Simon Willison's Weblog
Simon Willison's Weblog
L
LangChain Blog
T
The Exploit Database - CXSecurity.com
D
Darknet – Hacking Tools, Hacker News & Cyber Security
NISL@THU
NISL@THU
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Privacy International News Feed
Blog — PlanetScale
Blog — PlanetScale

Sunshine

SpringBoot定时任务@Scheduled注解详解 | Sunshine 大端模式、小端模式解析 | Sunshine 机器数、原码、反码、补码解析 | Sunshine Spring事件驱动模型实践 | Sunshine IDEA好用的几款插件 | Sunshine Linux使用yum安装MySQL详细步骤(CentOS7.3) | Sunshine Windows下MySQL解压版安装配置详细步骤 | Sunshine Java使用JDBC连接SQLServer数据库(二) | Sunshine Java使用JDBC连接SQLServer数据库(一) | Sunshine Git基本操作整理 | Sunshine Oracle序列创建和使用 | Sunshine Git批量清理本地分支 | Sunshine Statement.RETURN_GENERATED_KEYS获取自增id踩坑记录 | Sunshine
GitPages+Hexo搭建个人博客 | Sunshine
DongyangHu · 2019-11-28 · via Sunshine

前言

偶然间发现Hexo这款很不错的博客框架,能直接生成静态文件,可以很方便的进行部署,搭配GitPages简直不要太棒,省去了服务器的维护。支持Markdown,刚好符合我的习惯,因此决定使用Hexo+GitPages的方式搭建一个个人博客,欢迎访问Sunshine。此处记录搭建的过程。

GitPages的使用依赖于GitHub账号,若没有需要自行创建。

基本使用

  • 新建Repository,命名为<GitHub账户名>.github.io
  • Clone仓库到本地,并创建测试页面,命名为index.html,Push到远程GitHub,即可通过<GitHub账户名>.github.io访问到页面

自定义域名

  • 进入Repository的设置界面,在Custom domain填入域名地址
  • 配置域名解析,添加CNAME类型的记录,填入<GitHub账户名>.github.io

安装Hexo

Hexo依赖Node.jsGit,详细步骤可参考官方文档

使用npm安装Hexo

1
npm install -g hexo-cli

初始化博客目录

为自定义文件夹,Hexo会在该文件夹下创建博客文件。

1
2
3
hexo init <folder>
cd <folder>
npm install

启动博客服务器

在博客目录下,执行如下命令即可启动博客服务器,可以看到一篇示例博文。默认端口4000,访问地址为:http://localhost:4000

1
hexo server

新建文章

使用Hexo的命令创建一篇文章,会在source/_posts路径下生成对应的Markdown文件。关于创建文章的详细说明,参照官方文档

1
hexo new FirstPage

使用文本编辑器,编辑文章的内容,最好使用可视化的Markdown编辑器。启动博客服务,可看见新建的文章。

发布博客到GitPages

方式一:手动提交静态网页

使用将Hexo生成的静态网页文件手动提交到代码仓库的方式来发布博客。

  • 执行hexo generate命令,会在博客目录生成public文件夹,里面是打包的静态网页文件
  • public文件夹下的内容push到GitPages的仓库
  • 访问GitPages即可看到博客的内容

方式二:使用Hexo的deploy命令发布

通过配置Hexo的部署选项,部署博客到GitPages。

  • 安装hexo-deployer-git
1
npm install hexo-deployer-git --save
  • 编辑_config.yml配置文件,加入部署的相关配置
1
2
3
4
5
deploy:
type: git
repo: https://github.com/<username>/<username>.github.io
branch: [branch] #默认为master,GitPages的个人主页只能部署master分支,项目主页可选
message: [message]
  • 生成博客站点文件并部署至远程仓库
1
hexo clean && hexo deploy
  • 查看GitPages所在仓库文件是否更新,进入GitPages页面即可看到博客内容

总结

本篇文章只粗略的记录了主要步骤,更多详细使用说明请参照官方文档。

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Sunshine