LoginSignup
36
37

More than 5 years have passed since last update.

GitHub Pages でデモ用 Web サイトを無料公開する方法

Last updated at Posted at 2016-04-04

Qiita の記事を書いているときデモ用の Web サイトを作成して公開したいときがある。そんなときに GitHub Pages で静的な Web サイトを無料公開するのが便利なのでメモっとく。

GitHub にリポジトリを作成する

この記事では Repository name を github-pages-demo でリポジトリを作成する。

Screen Shot 2016-04-04 at 23.10.35.png

デモ用 Web サイトを制作する

$ mkdir github-pages-demo
$ cd github-pages-demo
$ cat > index.html << EOS
<!DOCTYPE html>
<title>Demo Website</title>
<h1>Demo Website</h1>
EOS

ローカルに Git リポジトリを作成してコミットする

$ git init
$ git add .
$ git commit -m "Add a demo website"

master ブランチを gh-pages ブランチに変更する

gh-pages ブランチのコンテンツが Web サイトとして公開される。GitHub Pages を利用したいだけのリポジトリなので master ブランチは不要。

$ git branch -m master gh-pages

gh-pages ブランチを GitHub リポジトリにプッシュする

$ git remote add origin https://github.com/takuya0301/github-pages-demo.git
$ git push origin gh-pages

takuya0301.github.io/github-pages-demo に公開される

Screen Shot 2016-04-04 at 23.19.25.png

36
37
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36
37