Github个人网站维护
Could not read Username for Github
fatal: could not read Username for 'https://github.com': Invalid argument
Go to the github repository of my personal computer,and running the following scripts in the terminal.
ssh-add ~/.ssh/id_rsa
git remote set-url origin [email protected]:username/repo.git
Create a ssh key
1- Create a ssh key using Git Bash using following command
ssh-keygen -t rsa -b 4096 -C "[email protected]"
After running this command just install the by default options and enter the password balnk when it prompts.
2- Then run the following commands to locate the public/private key generated from step1
cd .ssh
cd ~/.ssh
3- Then run the following command to view your public:
cat id_rsa.pub
4- Copy your public key and go to your GitHub account -> settings -> create a SSH and GPG keys then click new ssh key and past your public key in the in key text field.
5- Verify your public key using Git Bash by running the following command:
ssh -vT [email protected]
Hugo on github
- Create on GitHub
mywebsite-hugorepository (it will host Hugo’s content) - Create on GitHub
chengjun.github.iorepository (it will host the public folder: the static website) cd githubgit clone https://github.com/chengjun/mywebsite-hugo.githugo new site mywebsite-hugo --forcecd mywebsite-hugo- download Academic and extract it into a themes/academic folder within your Hugo website.
- If you are creating a new website, copy the contents of the exampleSite folder to your website root folder, overwriting existing files if necessary.
hugo server --watch- Once you are happy with the results,
Ctrl+C(kill server) andrm -rf public(don’t worry, it can always be regenerated with hugo -t) git submodule add https://github.com/chengjun/chengjun.github.io.git public --force- Almost done: add a deploy.sh script to help you
- and make it executable:
chmod +x deploy.sh ./deploy.sh "Your optional commit message"to send changes to.github.io (careful, you may also want to commit changes on the -hugo repo). #!/bin/bash echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" # Build the project. hugo # if using a theme, replace by `hugo -t <yourtheme>` # Go To Public folder cd .. cd chengjun.github.io cp -av /Users/chengjun/github/mywebsite-hugo/public/* . # Add changes to git. git add -A # Commit changes. msg="rebuilding site `date`" if [ $# -eq 1 ] then msg="$1" fi git commit -m "$msg" # Push source and build repos. git push origin master # Come Back cd ..
domain name
在godaddy上花了122块钱买了两年的域名 chengjunwang.com。简单设置cname和goddy上的a record和cname www record就好了。主要参考了这里。
我对于html的无知可以说是到了某种无以附加的程度。虽然我投入了很多时间,但往往都是干中学。而不是系统的模仿。通常会发现很多困惑,然后每次对我而言都是一个个小trick就解决了问题。
平行的文本框
如何添加一个平行的文本框?这个困惑了我很久的问题,解决方法是设置position为absolute。
#textbox {
position:absolute;
top: 200px;
width: auto;
margin-left: 50px;
background-color: rgba(0,0,0,0.2);
opacity:1;
}
修改之后又觉得不好看。又尝试了iframe,也不是很合适。
之后发现一篇好文章The Shapes of CSS.
修改了其中的talkbubble,放在application.css中。
#talkbubble {
position:absolute;
top: 250px;
margin-left: 50px;
width: 300px;
height: 150px;
background-color: rgba(0,0,0,0.2);
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#talkbubble:before {
content:"";
position: absolute;
margin-left: 300px;
top: 80px;
width: 0;
height: 0;
background-color: transparent;
#border-top: 5px solid transparent;
border-bottom: 30px solid rgba(0,0,0,0.2);
border-right: 120px solid transparent;
}
在index.html里加入talkbubble来显示新闻。
<div id="talkbubble">
<h2><a href="http://chengjun.github.io/cv/news.html">News</a></h2>
<p>[Feb 23] <a href="https://pypi.python.org/pypi/scholarNetwork/">scholarNetwork</a>--a python package which can help crawl and visualize the coauthor network of Google Scholar is released to Pypi. </p>
</div>
谷歌字体
俺天朝跟谷歌成了死敌。背后的很多想法让人很无奈。虽然米果是两党制,但是谷歌据说也在检查之列。到了俺朝,美利坚放不下身段了,天朝也放不下,于是就僵住了。于是很多谷歌的服务都不好用了。比如谷歌学术,谷歌邮箱。哎妈呀,老伤心老。我这里要说的却是谷歌的字体格式。
在天朝载入我的博客慢的原因就是因为style.css里(media/css/style.css)调用里谷歌字体。好伤心,每次访问速度都很慢,非得翻墙才行。可是不能让俺的读者们也翻墙吧,这也太虎了。反正我的审美要求也没那么高。雪藏了吧。
#@import url(//fonts.googleapis.com/css?family=Galdeano);
#@import url(//fonts.googleapis.com/css?family=Electrolize);
#@import url(//fonts.googleapis.com/css?family=Cuprum);
改过来之后
我了个去,怎么英文字体变这么大了,BIG好吧,只能骗自己感觉萌萌哒啦。
把谷歌字体放在本站
其实很早就注意到andy wang的这个解决方法,一直比较懒。还是去在mac上安装了github for mac,于是把andy wang的media文件夹偷到我这里来用。
Andy Wang:
你好,我扒走了你的模板,然后在天朝用发现非常慢,然后调试了一下,发现是在style.css和home.css里面有从别的网站下载字体文件的, http://fonts.googleapis.com/这个网站在天朝访问非常不稳定,所以做了一些小改动,把字体文件都下载到网站上了,页面渲染速度也快了很多。https://github.com/synckey/synckey.github.io/tree/master/media/css
终于,世界再次变得一片清凉了。真好。
categories
我喜欢在网页端更新github上的日志,通过设置只显示categories为blog的文档,我可以每次修改一点东西就完全在网页端写日志。图片附件什么的可以放在七牛网站,感觉非常好。
下面是我用来复制和重命名1000个md文本的python代码:
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 07 14:05:09 2014
@author: chengjun
"""
import shutil
path = "D:/github/chengjun.github.io/_posts/"
demo = path + "2010-01-01-demo.md"
for i in range(1000):
newFile = path + "2010-01-" + str(i) + ".md"
print newFile
shutil.copy(demo, newFile)
jekyll3.0
这个是一个测试,jekyll更新到了3.0版本,所以github也相应发生了改变(见这里)。这导致了我的文章无法显示,解决的方法是去掉表头的时间一行,就可以了,我还没有明白原因。
某一类的博文目录
主要参考 filtering-posts-using-categories-in-jekyll-bootstrap
这个是使用liquid写的,介绍见这里。
主要添加两行liquid代码:
if post.categories contains '生活'
不要忘记endif
由于liquid语言本身不能在本网站呈现,读者可以查看这里。
琢磨出一个不用每次在jekyll上写博客都要上传的方法:将要显示的博客的categories设为blog,一次上传n个草稿(不指定categories),使用liquid语言指定在博客列表中只显示blog类的。这样草稿不会被显示,每次在线登录github,更改一个草稿的标题和categories就可以了。图片用外链flickr。
paginator
今天下午鼓捣了半天jekyll的设置,最初是想弄一个paginator给文章列表分页,结果搞了半天,没搞定。各种问题。Patrick McKinley说是因为不是网站第一层的index.html,所以jekyll官方设置时没有用的。于是,直接用他的方法,发现没有办法在我的网站上实现。
Patrick McKinley的博客以图片来显示博客文章的方法似乎很酷。感兴趣,去研究了下他的代码,大致是设置了post.image,图片存放在assets中的图片文件夹。我弄了下,也没弄成功。
又看到Mr Trường at RMIT的网页,翻了半天,加了related_posts功能。
没想到晚上更惨,被python的encoding error搞得很头大!