怎样用github gh pagespages搭blog

Create a repository
Head over to
named username.github.io, where username is your username (or organization name) on GitHub.
If the first part of the repository doesn’t exactly match your username, it won’t work, so make sure to get it right.
What git client are you using?
Download GitHub for Windows
GitHub for Windows is a great way to use git and GitHub on Windows.
Download GitHub for Mac
GitHub for Mac is a great way to use git and GitHub on Mac.
Clone the repository
Go to the folder where you want to store your project, and clone the new repository:
~$git clone /username/username.github.io
Clone the repository
Click the green "Set up in Desktop" button. When the GitHub desktop app opens, save the project.
If the app doesn't open, launch it and clone the repository from the app.
Clone the repository
After finishing the installation, head back
and refresh the page. Click the green "Set up in Desktop" button. When the GitHub desktop app opens, save the project.
If the app doesn't open, launch it and clone the repository from the app.
Hello World
Enter the project folder and add an index.html file:
~$cd username.github.io
~$echo "Hello World" > index.html
Create an index file
Grab your favorite text editor and add an index.html file to your project:
&!DOCTYPE html&
&h1&Hello World&/h1&
&p&I'm hosted with GitHub Pages.&/p&
Add, commit, and push your changes:
~$git add --all
~$git commit -m "Initial commit"
~$git push -u origin master
Commit & sync
Enter the repository, commit your changes, and press the sync button.
Commit & sync
Enter the repository, commit your changes, and press the sync button.
…and you're done!
Fire up a browser and go to http://username.github.io.
Generate a site, or start from scratch?
For Project sites, you have the option to generate a site with one of the amazing pre-built themes, or to create a site from scratch.
Repository Settings
Head over to
and create a new repository, or go to an existing one. On the right hand side, click on Settings.
For Project pages, the gh-pages branch is used to publish your site. That means that you can work with GitHub Pages in the same repository as the project that it's for, without affecting the project itself.
Automatic Generator
Scroll down to the GitHub Pages module. Press the Automatic Page Generator button.
Add content
Use the editor to add content to your site. If you already have a README.md in your project, you can import that on the right hand side.
When you're done, click Continue to Layouts.
Pick a theme
Choose between the themes in the carouselle at the top. When you're done, click the Publish button on the right hand side.
Create a gh-pages branch
Head over to
and create a new repository, or go to an existing one. In the repository overview, click the branch drop-down on the left-hand side. Type in gh-pages and press enter.
For Project pages, the gh-pages branch is used to publish your site. That means that you can work with GitHub Pages in the same repository as the project that it's for.
Optional: Make gh-pages the default branch
If you created a new branch for GitHub Pages, enter the repository settings on the right hand side. In the top module, change the default branch to the newly created gh-pages branch.
Create an index file
Go back to the repository overview, and use the plus icon next to the repository name to create a new file.
Hello World
Name the file index.html and type in Hello World for the content.
Commit the file
Scroll to the bottom of the page, write a commit message, and commit the new file.
…and you're done!
Fire up a browser and go to http://username.github.io/repository.
Now that you’re up and running, here are a few things you should know.
Using , you can blog using beautiful Markdown syntax, and without having to deal with any databases. .
Want to use your own custom domain for a GitHub Pages site? Just create a file named CNAME
and include your URL. .
Learn how to create custom 404 pages, use submodules, and .GitHub+Markdown+Jekyll打造完美的个人博客。以前建过个人网站,也用过第三方的..
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
GitHub+markdown+jekyll打造完美个人博客
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口你的位置: >
> 在Github上搭建Octopress博客
本文将详细叙述在Windows下如何安装、运行Octopress博客并发布到Github Pages上,然后就可以通过来访问你的站点了。先看下我发布在Github上的Octopress演示博客:
演示地址:
绑定域名:
因为我已经绑定了域名,所以点击第一个演示地址时会自动跳转到绑定的域名上。
安装Octopress博客前需在本机上安装Ruby运行环境和Devkit,另外还要下载Octopress,更改gem的更新源,安装依赖项。本文将针对Github上的Octopress博客搭建进行详细说明。
一、搭建本地环境
为了在Github上使用Octopress,需要首先配置一下本地环境:
首先安装Git,下载,目前最新版本是 ,安装可参考。
然后安装Ruby,中指定的 Ruby 版本是 1.9.2,所以我们选择 Ruby 1.9.2-p290,下载 ,双击安装,安装时记得选中“Add Ruby executables to your PATH”。
为了检查ruby是否已加入到PATH中,可在 Windows 的cmd窗口中执行以下命令:
ruby –version
接着安装Devkit,选择下载 4.5.2 版本:,下载完成后,将其解压到如 E:\DevKit,然后在win的cmd窗口中执行如下命令进行安装:
ruby dk.rb init
ruby dk.rb install
最后安装python,主要是博客代码加亮模块需要python环境的支持,,安装完以后,在Windows的cmd窗口中执行:
easy_install pygments
本地环境配置结束。
二、更新本地环境配置
为了支持中文UTF-8编码,对Windows环境变量配置如下:
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8
也可在直接在Windows的cmd窗口下运行命令
set LANG=zh_CN.UTF-8
set LC_ALL=zh_CN.UTF-8
更新gem的更新源,ruby的官方更新源经常被河蟹,换成国内的更新源,这样速度就快多了,变更如下:
gem sources -a http://ruby.taobao.org/
gem sources -r http://rubygems.org/
gem sources -l
最后一个命令可查看更该后的更新源列表。
三、下载并配置Octopress
首先下载Octopress源码,可以使用下面git命令下载,也可直接在Octopress Github库中下载octopress的zip包(),然后将下载的压缩包解压到E盘根目录,修改解压后的文件夹名称为 octopress。
git clone git:///imathis/octopress.git
然后更新 Octopress 的gem更新源:进到 E:octopress 目录,用文本编辑器(例如记事本)打开文件Gemfile,将里面source “http://rubygems.org/”改为source “http://ruby.taobao.org/”。
最后安装Octopress的依赖项,在Windows的CMD窗口输入以下命令:
cd octopress
gem install bundler
bundle install
四、新建Github Repositories
登录,假设你的用户名是username,首先要新建一个命名为
的Repo,命名必须是这个格式,如果不这样命名的话,在运行命令 rake setup_github_pages
之后不能够自动创建后面提到的master和source 分支,而是作为普通仓库生成 gh-pages 分支。
创建Repo,如下图:
Repo的设置,如下图:
五、发布Octopress到Github
1、打开Windows下的命令窗口,进入到Octopress所在的目录,输入命令:
rake setup_github_pages
按照提示输入刚才新建的Repo地址,类似::username/或:username/.git。
2、接着输入命令:
rake install
rake generate
rake preview
其中rake install是安装Octopress默认主题的,rake gnerate是生成静态页面的,这两个命令是必须运行的,而rake preview则是用来本地浏览的(运行时看屏幕上提示,按Ctrl+C并输入Y来终止批处理操作),运行后打开浏览器,输入
就可以看到如下的界面了,不想预览的话也可以不运行,直接进入下一步。
3、将博客发布到Github上,输入下面命令:
rake deploy
这样,生成的内容将会自动发布到master分支,并且可以使用
访问内容。
4、别忘了把所有源文件发布到 source 分支下面:
git commit -m “your message”
git push origin source
至此,所有发布完成,接下来就是对博客的设置了。
六、Ocotpress博客配置
更改下面的配置后,还需要运行 rake generate、rake deploy等等命令的。
1、默认的博客运行成功的话,就需要按照自己的要求对博客配置进行修改了,主要是修改Octopress根目录下的主配置文件_config.yml。
# 博客地址
# 博客标题
感受生活,感悟工作,感触心灵
simple_search:
.hk/search
# 搜索引擎
description:
# 关于博客的描述
subscribe_rss:
# Rss订阅地址, 默认是
subscribe_email:
# 提供Email订阅的地址
# Rss订阅的Email地址
# 博客路径,默认是“/“,如果你打算在子目录中,记得修改这个路径
permalink: /blog/:year/:month/:day/:title/
# 文章的固定链接形式
2、更换主题
主题位于 octopress/.theme 目录下,默认主题为 classic。 如果需要更改主题(可在网上查找),下载后将主题也放在.theme目录下即可,如果主题名字为blog_theme,那么安装主题时输入以下命令即可:
rake install [‘blog_theme’]
七、绑定域名
Github Pages绑定域名的方法有点特殊,需要在Octopress/source目录下建个无后缀的CNAME文本文件,文件内容就是你的域名,例如,然后修改A纪录到207.97.227.245 ,或者 CNAME 指向 ,下面就等着解析生效了。
更多内容可参考这里:
欢迎转载,转载请注明出处: &
与本文相关的文章基于GitHub Pages搭建个人博客
Github作为全球最流行的代码仓库,已经得到越来越多的公司和项目的青睐。如何让世界各地的程序员协作开发,
为此GitHub提供了GitHub Pages服务,我们可以利用这个服务建立站点,将你的使用文档,说明文档等放入其中,供他人阅读使用。
当然我们也可以用它来建立自己的个人博客站点。
轻量级的博客系统,你不需要做烦人的配置,不需要搭建服务器。
jekyll使用Liquid模板语言,使用标记语言,比如Markdown。
不限空间。
可以绑定自己的域名。
只能生成静态网站,适合博客,文档介绍等。
没有评论等动态交互程序,但是可以通过第三插件实现。
对于使用者要求有一定的开发基础,可能更适合程序员等使用。
以下所有操作都是基于Windows操作系统环境。
注册GitHub账号
使用托管代码,必须现在上注册一个账号。
,使用默认安装,安装完成后即可使用Git。
配置和使用GitHub
打开 Git Bash
1、检查SSH key设置
查看自己电脑上的SSH key设置:
$ cd ~/.ssh
如果提示为“No such file or directory”,直接跳到第三步,否则继续。
2、备份以及删除旧的SSH key
为了保险起见,先备份后再重新生成:
id_rsa.pub
known_hosts
$ mkdir key_backup
$ cp id_rsa* key_backup
$ rm id_rsa*
3、生成新的SSH key
填写你自己的GitHub邮件地址,提示要输入信息的地方直接回车就OK:
$ ssh-keygen -t rsa -C "邮件地址@"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
把生成的key文件复制到C:\Documents and Settings\Administrator\.ssh\目录下。
必须把id_rsa、id_rsa.pub这两个文件放到当前用户目录的“.ssh”目录下才能生效。
在windows中只能在命令行下输入创建“.”开头的文件夹,命令为:
$ mkdir .ssh
4、GitHub SSH key设置
设置Git用户信息
第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,
所以会随更新内容一起被永久纳入历史记录,用户名称必须是你GitHub真实的账号名称:
$ git config --global user.name "username"
$ git config --global user.email
Git和GitHub之间使用SSH连接,必须在GitHub上设置好key,才能正常连接。
进入GitHub主页,进入账号设置:
点击左侧SSH keys选项,点击Add SSH key,然后打开C:\Documents and Settings\Administrator\.ssh\目录下id_rsa.pub文件,
复制里面的内容粘贴到key文本框中,点击保存即可:
5、测试SSH连接
输入下面命令测试SSH连接是正常:
提示以下信息,表示SSH连接成功:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
恭喜你,现在你可以使用Git向GitHub提交东西。
建立自己的博客
使用建立自己的博客。
GitHub Pages提供两种方式建立博客站点:
基于用户或组织的站点(User or organization site)。
基于项目的站点(Project site)。
用户或组织站点(User or organization site)
你必须建立一个项目名称为username.github.io的项目,其中username是在Github上的用户名。
使用此种方式建立站点后,当你访问http://username.github.io/时,Github会解析用户username下的master分支下的项目源代码,
生成静态网站,并将生成的index.html文件展示给你。我就是使用这种方式建立的博客。
打开Git bash,在你需要保存项目的目录下clone刚才建立的项目username.github.io
$ git clone /username/username.github.io
使用下面命令,进入项目根目录,建立一个index.html文件,提交文件
$ cd username.github.io
$ echo "Hello World" & index.html
$ git add --all
$ git commit -m "Initial commit"
$ git push
恭喜你,你的博客站点建立成功,访问http://username.github.io/即可,
第一次生成站点时,大概需要10左右延迟时间,后续修改提交后,会立即生效。
项目站点(Project site)
这种方式跟第一种方式后台程序处理机制是一样的,只是访问方式不一致。
使用http://username.github.io/repository访问,GitHub会自动解析username用户下的
repository项目的gh-pages分支源代码,生成静态网站并展示给你,所以你必须在项目下建立名为gh-pages的分支。
使用这种方式更适合为每个项目建立使用说明文档之类的站点。
你可以通过两种方式建立:
1、自动生成站点:
2、建立gh-pages分支生成站点:
建立gh-pages分支,添加index.html文件。
大概需要10左右延迟时间,你就可以使用http://username.github.io/repository访问你的站点了。
至此一个简单的个人博客框架搭建好了,你只需要往里面添加文件以及内容就行了。
后续我将继续写一个博客,如何搭建一个jekyll windows环境,这样就可以在本地进行内容修改添加,在本地预览无误后再发布到GitHub。
Please enable JavaScript to view the推荐这篇日记的豆列
······}

我要回帖

更多关于 github pages极简教程 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信