hello-world
GatsbyをGitHub Pagesに出力する。とりあえず、hello-worldをGitHub Pagesにpushしてdeployをするという説明通りにやってみよう。
まず、GitHubにhello-worldのRepositoriesを新しく作るという手順だったが、先にGatsbyでhello-worldのフォルダーを作ってしまったので、hello-worldのファルダー名を変えておいてgitでcloneしてから中のファイルを上書きする。
GitHubにhello-worldのRepositoriesを新しく作ってから、GitHub Desktopでさっきのフォルダーにクローンしてからよけていたフォルダー内のもので上書き。githubにcommitしてpushした。
GitHubのSettingsからGitHub PagesのBranchでmain rootを選んでsaveしたら。Gatsbyの説明ページがGitHub Pagesに表示された。
npmのgh-pagesのパッケージをインストールするらしい。
npm install gh-pages --save-dev
pathPrefixにhello-worldを指定
gatsby-config.jsに以下を追加
module.exports = {
pathPrefix: "/hello-world",
}
package.jsonに追加
{
"scripts": {
"deploy": "gatsby build --prefix-paths && gh-pages -d public"
}
}
npm run deployを実行
そうするとbranchにgh-pagesが追加されている。
GitHub PagesのBranchでgh-pagesを指定してsaveする。
そうすると下のページのように表示された。
https://kyukyunyorituryo.github.io/hello-world/