0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

mkdocsをMacにインストールする。

Last updated at Posted at 2020-04-20

#mkdocsとは?
mkdocsは自動的にMarkdownによりWebページを自動生成してくれる便利なツールです。

#pythonのインストール
Webサイトよりpython3をダウンロードしてウィザードに従いインストールします。

$python3 --version

pip3も使えるようになるはず。
$pip3 --version
最新は、3.8
※最近のMacOS(Monterey)はインストールしているはずです。

できない場合は、
$sudo sudo easy_install pip

#mkdocsのインストール(例)

$pip3 install mkdocs
最新は1.2.3(2021年)

#mkdocsのバージョン確認

$mkdocs --version

パスが通っていない場合は

$cat \$SHELL

/bin/zsh

zshの場合は、

cd ~

sudo vi .zshrc

export PATH=/Users/MyName/Library/Python/3.8/bin:$PATH

source ~/.zshrc

#mkdocs任意のアップグレードまたはグレードダウンする場合は、
$pip3 install --upgrade mkdocs==1.0.4

pipによるパッケージバージョン一覧

$pip3 list

#マテリアルインストール
$pip3 install mkdocs-material

$pip3 install pygments

$pip3 install mkdocs-macros-plugin

$pip3 install fontawesome_markdown

#mkdocsテスト

$ mkdocs new test

$cd test

# ダウンロードする場合は
$git clone https://github.com/任意のレポジトリ/****.git

ブランチの切り替え

ブランチはmasterとgh-pagesが通常あります。
デフォルトのブランチがgh-pagesの場合は、
$git checkout master でブランチを切り替えます。

テキストエディタ等でmdファイルを編集しましたら、
ymlファイルがあるディレクトリ上で

$mkdocs build

html、jsなどが更新されます。

デプロイする場合は、
$mkdocs gh-deploy
が実行されページが更新されます。

mdファイルのmasterブランチも一緒に更新しましょう。
$git commit -m "変更内容"

$git push -u origin master

mdファイルとymlファイルが生成されます。
mdファイルはサイトの内容が入り、ymlファイルはwebサイトのテーマになります。

ローカルでサーバーが立ち上げます
$mkdocs serve

ブラウザで内容を確認します。
http://127.0.0.1:8000

新規レポジトリを追加の場合は、

$git init

変更追加した場合は、

$git add .

$git commit -m "first commit"

$git push -u origin mastergit remote add origin https://github.com/takeo/takeochan01.git

## すでにサイトがある場合は、
$git clone https://https://github.com/takeo/takeochan01.git

$git pull origin master

#Gitの設定確認

$cat ~/.gitconfig

デプロイします。

$mkdocs gh-deploy

※Githubがパスワード認証をやめました。秘密鍵と公開鍵を作成後、githubに登録。
Macでは、ghコマンドを使ってクローンするといいみたいです。

#Gitコマンドメモ

リモートと同期する

$git fetch origin

 ローカルの更新履歴

$git log

ローカルのブランチのリスト

$git branch -a

ブランチの切り替え

$git checkout master

$git checkout gh-pages

リモートのマスターブランチにプッシュ

$git push -u origin master

0
3
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
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?