GitHub contents
GitHub PagesからあらゆるGitHub関係の記述をお引越し。
迷子なURL対策
かなり前というか、1995年から作っていたサイトに、今でもLinux系のリンク経由で飛んできていたのにびっくり。
ありがとう、Check your website’s backlinks -SEO Toolbox
なので、GitHubからリダイレクトするように設定してみた。
_layouts/redirected.htmlに、こういうファイルを作成。
Gemfileにも追加。
group :jekyll_plugins do
gem 'jekyll-redirect-from'
end
_config.ymlに追加。
plugins:
- jekyll-redirect-from
リダイレクトしたいURLのある場所に、ファイルを設置。
例としてあげたのは、実際に最近も廻ってきているらしい、Linux関係の設定。
どこにも書いてなかったが、フォルダは/_Linux/
ではなく、アンダーバー無しの/Linux/
に置くべし。
嘘ですごめんなさい、フォルダは自由です。permalink
さえちゃんと設定されていれば、どこに置いても問題無しです。
自分の場合はredirected
フォルダに放り込んであります。
---
layout: redirected
sitemap: false
permalink: /Linux/
redirect_to: https://1995.treetop.to/Linux/
---
あとは通常通りにbundle update
やらjekyll
sやらでできた。
お試しで/Linux/indexにアクセスすると、スパーンっとリダイレクトされるように。
手元のファイル群を管理したい
GitHub Pagesから離れているので、あとで別の場所に置き直すかも。
- 管理したいファイル群が入っているフォルダに移動して、git用に初期化
$ git init
- さっそく中身を見てみると、こんな感じで戻ってきた1
$ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) ... nothing added to commit but untracked files present (use "git add" to track)
- 全部放り込む
$ git add -A
- そして、コメントを付けてcommit
$ git commit -m "new repository from existing files" [master (root-commit) 16cfb94] new repository from existing files nn files changed, nnn insertions(+) ...
- こう?
$ eval `ssh-agent` Agent pid nnnn
- でもって?
$ ssh-add ~/.ssh/id_rsa Identity added: /c/Users/<user>/.ssh/id_rsa (/c/Users/<user>/.ssh/id_rsa)
- GitHub上で空のリポジトリを作成(上記「リポジトリを作成」参照)
- 追加
$ git remote add origin https://github.com/<user>/<repogitory>.git
- もし
fatal: remote origin already exists.
というエラーが出たら、こんな状態になっているかと$ cat .git/config [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://github.com/<username>/<repository>.git fetch = +refs/heads/*:refs/remotes/origin/*
- 下記コマンドを実行
$ git remote rm origin
- 確認
$ cat .git/config [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true
- その状態で
git remote add ...
を実行
- もし
- そして放流(?)
$ git push -u origin master Counting objects: 19, done. Delta compression using up to 4 threads. Compressing objects: 100% (16/16), done. Writing objects: 100% (19/19), 524.54 KiB | 22.81 MiB/s, done. Total 19 (delta 0), reused 0 (delta 0) To https://github.com/<username>/<repository>.git * [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.
noindex, nofollow
各記事のFront Matterか、または_config.yml
の記事生成設定に追加
robots: "noindex, nofollow"
_includes/head.html
に追加
{% if page.robots %}
<meta name="robots" content="{{page.robots}}" />
{% endif %}
これだけで、生成したらタグが追加されるように。
<meta name="robots" content="noindex, nofollow" />
robotsに限らず、metaタグを増やせそうな。
-
インデントがおかしくなるので、空白行は削除してます。 ↩