Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [設計發想 SOP](design.md)
- [Sketch 學習資源](sketch.md)
- [Hexo](hexo.md)
- [Git SSH Key 建置](ssh_key.md)

- 進階

Expand Down
33 changes: 29 additions & 4 deletions hexo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ Hexo 是基於 Node.js 網誌框架,文章的寫作只要使用 Markdown 語

## 安裝

安裝 Hexo 前,需有以下軟體
安裝 Hexo 前,需先完成以下事項

- Node.js
- Git
- Node.js 安裝
- Git 安裝
- 建立 [Git SSH Key](ssh_key.md)

有上述軟體時,使用 NPM 安裝 Hexo
上述事項完成後,使用 NPM 安裝 Hexo

```
$ npm install -g hexo-cli
Expand Down Expand Up @@ -59,6 +60,19 @@ $ npm install hexo-deployer-git --save

- `_config.yml` 設定

```
url:
// 網站的網址
root:
// 網站根目錄
permalink: :year:month:day/:title/
// 文章的連結格式
```

`url` 、 `root` 未設定 deploy 上去的 blog 會發生以下圖例

![hexo-borken](/images/hexo-borken.png)

```
deploy:
type: git
Expand All @@ -85,6 +99,17 @@ $ hexo clean

清除快取檔案或是以產生的靜態檔案

## 更換主題

依照要更換主題的文件做指令操作,大多主題直接使用 `git clone` 把主題專案放進自己 Blog

的 `/themes` 中,然後再到外部的 `_config.yml` 下,把原本的主題名稱改成新的即可。

```
theme: landscape -> 新主題名稱
```

修改完成,可以使用 `hexo s` 在本地端預覽查看,沒問題就可以用 `hexo d` ,把新主題推到 Github pages 上了。

## 參考資料

Expand Down
Binary file added images/git-ssh01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/git-ssh02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hexo-borken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions ssh_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Github 目前提供兩種方式來進行遠端 repo 的操作,使用 HTTPS 或SSH。

如果使用 HTTPS 來進行操作的話,每次push程式碼都還必須要輸入帳號密碼,若使用 SSH,則只要設定過一次 Public Key之後,進行任何操作就不需要輸入帳號密碼, 讓 Git 的操作更加方便。

以下將說明生成 SSH Key 的步驟:

### 檢查是否有相關 SSH Key 存在

假如不確定以前是否有做過 SSH Key 的話,可以先檢查電腦是否有檔案。

1. 開啟 **命令提示字元** 或是 **Git Bash**
2. 在程式中輸入 `ls -al ~/.ssh` 來檢查是否有相關檔案

```
$ ls -al ~/.ssh
```
一般預設的公共密鑰文件為下列其中之一

- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub

### 製作 SSH Key & 加入 SSH-Agent

###### 製作 SSH Key

1. 開啟 **命令提示字元** 或是 **Git Bash**

2. 輸入或是貼上下列指令, 並在 `""`中輸入自己的 GitHub email

```
$ ssh-keygen -t rsa -b 4096 -C "GitHub email address"
```
3. 輸入完按 `ENTER` 後會出現下列訊息:

```
Enter a file in which to save the key (/Users/you/.ssh/id_rsa)
```
可直接 `ENTER` 下一步

4. 設定 SSH Key 密碼

```
Enter passphrase (empty for no passphrase): 輸入密碼
```
```
Enter same passphrase again: 再輸入一次密碼
```

##### 加入 SSH-Agent

1. 確認 ssh-agent 啟動

```
$ eval "$(ssh-agent -s)"
```

##### 將 SSH Key 加入 GitHub 帳號中

1. 輸入以下指令,複製 SSH Key 至剪貼簿

```
$ clip < ~/.ssh/id_rsa.pub
```

2. 至 GitHub 頁面中,點選右上頭像旁的倒三角形,點選 `Settings`

![](/images/git-ssh01.png)

3. 在左側設定列表中點選 `SSH and GPG keys`

![](/images/git-ssh02.png)

4. 選擇 `New SSH key`

5. **Title** 自行設定自己想要的名稱,把前面複製的 SSH Key 貼到中間框框裡,最後選擇 `Add SSH Key`

6. 選擇 `Add SSH Key` 後,需要輸入 GitHub 密碼做確認,確認成功後就完成把 Key 放進 GitHub 中了!

### 測試 SSH Key 聯繫

1. 開啟 **命令提示字元** 或是 **Git Bash**
* 輸入以下指令

```
$ ssh -T git@github.com
```
會出現以下相關訊息

```
The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
```
```
The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
```
輸入 `yes` ,出現以下訊息代表連結成功!
```
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.
```

參考資料:

[Generating an SSH key](https://help.github.com/articles/generating-an-ssh-key/)