[转载]在github上建立Vimwiki

在github上建立Vimwiki
目录
参考:
如何搭建一个独立博客——简明Github Pages与Hexo教程: http://cnfeat.com/2014/05/10/2014-05-11-how-to-build-a-blog/
git - 简明指南: http://rogerdudler.github.io/git-guide/index.zh.html
准备工作
申请域名(可选,没有域名使用username.github.io方式访问)
在github.com注册用户
本地生成sshey:
命令:ssh-keygen -t rsa -C "说明信息"
会提示输入passphrase(密码),这个密码会在你提交项目时使用,如果为空的话提交项目时则不用输入;
完成后在~/.ssh/目录中生成两个文件:id_rsa(私钥)和id_rsa.pub(公钥,用于设置到github中)。
设置本地~/.ssh/config配置可定制ssh key路径
Host github.com
Hostname github.com
User git
Identityfile /your_path/git_rsa
添加SSH Key到GitHub:
登陆github系统,点击右上角的 Account Settings—->SSH Public keys —-> add another public keys
把你本地生成的密钥(~/ssh/id_rsa.pub)内容复制到里面(key文本框中),点击 add key 就ok了。
测试登录:ssh -T git@github.com,若成功会显示:
Hi xstarcd! You've successfully authenticated, but GitHub does not provide shell access.
建立Wiki
GitHub Pages Basics: https://help.github.com/categories/github-pages-basics/
GitHub Pages种类
与GitHub建立好链接之后,就可以方便的使用它提供的Pages服务,GitHub Pages分两种:

用户&组织页面:User & Organization Pages
项目页面:Project Pages
详细说明:https://help.github.com/articles/user-organization-and-project-pages/
User & Organization Pages
用户&组织页面存放在一个特定的仓库中,专用于GitHub页页文件。创库必须以GitHub用户名建立,如: atmos/atmos.github.io
每个git用户只能建立一个。
master分支将用于生成和发布到站点。
页面建立成功后,可用如下形式访问:
http(s)😕/.github.io
http(s)😕/www.yourdomain.com (使用CNAME方式绑定自定义域名)
Project Pages
Creating Project Pages manually:https://help.github.com/articles/creating-project-pages-manually/
与用户&组织页面不同,项目页面与项目存放在同一仓库中。
访问形式:
个人帐户项目页: http(s)😕/.github.io/
组织项目页:http(s)😕/.github.io/
与用户&组织页有少许差别:
使用gh-pages分支建立和发布项目页站点;
项目页站点URL要多一级项目名称;
自定义404页面仅在使用自定义域名时有效,否则使用用户&组织页的404页面。
建立页面仓库
登录后系统,在github首页,点击页面右下角「New Repository」建立仓库;
填写如下项目信息,点击「Create Repository」完成创建。
project name:xstarcd.github.io
description:XStar's Wiki
注意:
Github Pages的Repository名字是特定的,比如我Github账号是xstarcd,那么我Github Pages Repository名字就是xstarcd.github.io。
Wiki或Blog:branch设置为:master
项目页面:branch设置为:gh-pages
创建页面
/index.html

XStar's Wiki XStar's Wiki 测试访问: http://xstarcd.github.io ,应该可以看到站点首页了。 使用git发布Wiki Vimwiki是在本地用Vim进行Wiki编辑和页面生成,将Vimwiki生成目录做为git仓库来push到GitHub中,即可达到Wiki发布的目的。

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

从github clone到本地

git clone git@github.com:xstarcd/xstarcd.github.io.git
git branch # 查看分支列表
git pull # 更新本地仓库至最新更新
git checkout master # 切换至master分支

设置本地git配置

git config user.email 'xstarcd@users.noreply.github.com'
git config user.name 'xstarcd'
git config push.default simple
git config -l

git config -e # 直接编辑配置文件

git config --global --unset credential.helper #删除设置

更新README.md到本地仓库

cat >README.md <<EOF

XStar's Wiki

http://xstarcd.github.io/

http://w.gdu.me/

EOF
git add README.md

将建立wiki子目录,将Vimwiki html生成目录指向wiki子目录(设置方式见Vimwiki说明),并执行页面生成

...

将wiki子目录添加至本地仓库

git add *

git add wiki

提交至本地仓库

git commit -m 'first commit'

查看状态和变更

git status

推送更新到github

git push -u origin master

git push

查看日志,添加tag

git log
git tag 1.0.0 <提交ID前10位字符> # 创建一个1.0.0的标签
完成即可使用 http://xstarcd.github.io/wiki/ 来访问Wiki。

绑定自定义域名
参考
Setting up a custom domain with GitHub Pages: https://help.github.com/articles/setting-up-a-custom-domain-with-github-pages/
Adding a CNAME file to your repository:https://help.github.com/articles/adding-a-cname-file-to-your-repository/
Tips for configuring a CNAME record with your DNS provider
关于自定义域名处理规则:https://help.github.com/articles/about-custom-domains-for-github-pages-sites
添加/CNAME文件(只能添加一个域名)
w.gdu.me
设置域名解析
在DNS服务器中,添加域名CNAME记录,指向username.github.io,如:
w.gdu.me -> xstarcd.github.io
设置一个www子域名
如果你设置了顶级域名(如:example.com)和www子域名(如:www.example.com),GitHub服务器将自动进行两个域名的重定向:
如果CNAME文件中设置的是example.com,则www.example.com自动重定向到example.com;
如果CNAME文件中设置的是www.example.com,则example.com自动重定向到www.example.com;
你也许希望能够指定非www的子域名进行重定向,这仅能用于"User and Organization Pages",不适用于项目页。
自定义域名重定向规则
类型 GitHub主机地址 重定向规则 自定义域名范例
User Pages site username.github.io 自动重定向到CNAME中设置的自定义域名 user.example.com
Organization Pages site orgname.github.io org.example.com
Project Pages site owned by a user account username.github.io/projectname 自动重定向到含子路径的、User Pages site指定的自定义域名:user.example.com/projectname project.example.com
Project Pages site owned by an organization orgname.github.io/projectname 自动重定向到含子路径的、Project Pages site指定的自定义域名:org.example.com/projectname project.example.com
域名CNAME文件范例
atmos.github.io仓库的CNAME文件中设置为:www.atmos.com。

User Pages站点: atmos.github.io -> www.atmos.org
Project Pages站点: atmos.github.io/warden-github -> www.atmos.org/warden-github
注意:Project Pages站点继承所有者的User Pages站点的域名
emoji仓库CNAME设置为emoji.muan.co,所有者为muan,其User Pages仓库CNAME设置为muan.co。

其Project Pages站点muan.github.io/emoji重定向到muan.co/emoji,并且emoji.muan.co也可用。

其它
git.conf内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[user]
email = xstarcd@users.noreply.github.com
name = xstarcd
[remote "origin"]
url = git@github.com:xstarcd/github.io.git
fetch = +refs/heads/:refs/remotes/origin/
[branch "master"]
remote = origin
merge = refs/heads/master
[color]
ui = true
设置密码缓存
如果使用https方式clone仓库,每次push时均需求输入用户名和密码,可使用credential helper记录、并自动告诉GitHub用户名和密码(需要Git 1.7.10以上版本)。

git config --global credential.helper wincred

测试使用wincred没有效果,第二次pull还是提示输入username,password。

改用store有效。

http://git-scm.com/docs/git-credential-store
git config --global credential.helper 'store [options]'
保存位存:~/.git-credentials

Jekyll
github Pages和Jekyll入门: http://www.ruanyifeng.com/blog/2012/08/blogging_with_jekyll.html
Liquid模板语言: https://github.com/shopify/liquid/wiki/liquid-for-designers
https://github.com/ZE3kr/ZE3kr.github.io

posted @ 2018-03-14 01:27  庚庚  阅读(161)  评论(0)    收藏  举报