だいぶ前に、
ページのstatic site generator
をReact
がstatic site generator
を
前提
環境情報
以下、
* node.js
% node -v v8.4.0
npm
% npm -V npm@5.3.0 /usr/local/lib/node_modules/npm
gatsby
% gatsby -V 1.1.7
公開先の domain、 deploy方法等
自分の
github.io に User site と して 公開する。 gastby を
含む、 html 生成前の コンテンツは bitbucket で 管理、 公開用の コンテンツ類は github.io リボジトリで 管理する。
参考
macosx 設定メモ rsync 編 - Qiita
React.js製の
React.js製の
ブログを
Deploying Gatsby | GatsbyJS
目次
インストール、 Startersの 選択
インストール
GatsbyJS に
コマンドラインツールの
インストール npm install --global gatsby-cli
サイト作成
確かに結構時間が かかりました。 gatsby new gatsby-site --------------------------------------- added 1381 packages in 42.49s ---------------------------------------
ローカルサーバ の
起動
作成したsite ディレクトリに 移動します。 ローカルサーバ をcd gatsby-site
起動します。 gatsby develop --------------------------------------- I Your site is running at http://localhost:8000 I Your graphql debugger is running at http://localhost:8000/___graphql --------------------------------------
http://localhost:8080
にアクセスすると 画面が 立ち上がります。
Starters の 選択
いくつか
material デザインの
Vagr9K/gatsby-material-starter: A blog starter with Material design in mind for GatsbyJS.
他の Starters に
Starter ベースの
サイト作成 gatsby new YourProjectName https://github.com/Vagr9K/gatsby-material-starter
ローカルサーバ の
起動
site ディレクトリに移動します。 ローカルサーバ をcd YourProjectName
起動します。 起動後はgatsby develop
以下の サイトが 立ち上がります。 1
Gatsby Material Starter
[1] デモサイトへのリンクです。
gatsby-material-starter の 設定変更、 カスタマイズ
gatsby-material-starter の
実施したのは、
- 自分が
使用する github.io に 合わせて、 "./data/SiteConfig.js"
を編集する。 - レイアウト、
色を 変える。 - 個人的に
不要な components を 削除する。 - robots.txt の
修正
1. 自分が 使用する github.io に 合わせて、"./data/SiteConfig.js"
を 編集する。
SiteConfig.js
各種設定が、"./data/SiteConfig.js"
に
デフォルトの
module.exports = { blogPostDir: 'sample-posts', // Blog 投稿の配置先ディレクトリ content 配下のディレクトリを指定する siteTitle: 'Gatsby Material Starter', // サイトタイトル siteTitleAlt: 'GatsbyJS Material Starter', // meta タグに出力するサイトタイトル siteLogo: '/logos/logo-1024.png', // meta タグ、JSON-LD 内 に出力するlogo 画像を指定 siteUrl: 'https://vagr9k.github.io', // サイトのURLを指定する pathPrefix: '/gatsby-material-starter', // サイトの URL に付与する prefix 、ドメイン直下の場合は、"/" でOK siteDescription: 'A GatsbyJS stater with Material design in mind.', // サイトのDescription を指定 siteRss: '/rss.xml', // rss.xml のパスを指定する siteFBAppID: '1825356251115265', // Facebook の Appliaction ID。 これも headerタグで使われる。 siteGATrackingID: 'UA-47311644-4', // GA の Tracking ID disqusShortname: 'https-vagr9k-github-io-gatsby-material-starter', // Disqus の shortname. postDefaultCategoryID: 'Tech', // 投稿のデフォルトカテゴリ userName: 'Material User', // ユーザ名 userTwitter: '', // Optionally renders "Follow Me" in the UserInfo segment. userLocation: 'North Pole, Earth', // ユーザの所在地を指定。 userAvatar: 'https://api.adorable.io/avatars/150/test.png', // ユーザのプロフィール画像を指定する userDescription: "Yeah, I like animals better than people sometimes... Especially dogs. Dogs are the best. Every time you come home, they act like they haven't seen you in a year. And the good thing about dogs... is they got different dogs for different people.", // ユーザの紹介文 を記載。 Aboutページで使われる。 // ナビゲーションバーに表示する SNS リンクに設定するURLを設定する userLinks: [ { label: 'GitHub', url: 'https://github.com/Vagr9K/gatsby-material-starter', iconClassName: 'fa fa-github', }, { label: 'Twitter', url: 'https://twitter.com/Vagr9K', iconClassName: 'fa fa-twitter', }, { label: 'Email', url: 'mailto:vagr9k@gmail.com', iconClassName: 'fa fa-envelope', }, ], copyright: 'Copyright © 2017. Material User', // Footer と RSSに記載するコピーライト表示 };
- GAの
アカウント設定、 Tracking ID の 発行 - Facebook の
App ID の 発行 - サイトロゴの
準備 - アバター画像の
設定
3. 個人的に<wbr>不要な<wbr> components を<wbr>削除する。<wbr>
でDiscus
のdisqusShortname
を
gatsby-config.js の SiteConfig.js読み 込み 記述
初期設定から、gatsby-config.js
は
SiteConfig.js
と、gatsby-config.js
のgatsby-config.js
をSiteConfig.js
の
const config = require("./data/SiteConfig");
2. レイアウト、 テーマの 色を 変える。
レイアウトと、
Home の レイアウト変更
デフォルトだと、
これを
対象ファイルは、
以下を
1行、
2投稿に する。
横幅についてclassNameで、 <card key="{postInfo.path}" raise classname="md-grid md-cell md-cell--12">
と指定されています。
<card key="{postInfo.path}" raise classname="md-grid md-cell md-cell--6">
に変更します。 説明文、
カテゴリの 削除
CardTitle
、CardText
タグを削除します。 <CardTitle expander={expand} avatar={<Avatar icon={<FontIcon iconClassName="fa fa-calendar" />} />} title={`Published on ${postInfo.date}`} subtitle={`${postInfo.timeToRead} min read`} /> <CardText expandable={expand}> {postInfo.excerpt} <PostTags tags={postInfo.tags} /> </CardText>
テーマの 色を 変える
色の定義は、src/layouts/theme.scss
を
以下、md-blue-grey
系の
@import '~react-md/src/scss/react-md'; $md-primary-color: $md-blue-grey-800; $md-secondary-color: $md-blue-grey-300; $md-tertiary-color: $md-grey-50; .main-container, .darker-background { background-color: $md-tertiary-color; } a:link { color: $md-secondary-color; text-decoration: none; } a:visited { color: $md-blue-600; } a:hover { color: $md-blue-900; } a:active { color: $md-blue-300; }
3. 個人的に 不要な components を 削除する。
Discus は
- Discus 関連の
記載 の 削除
対象は、gatsby-material-starter/post.jsx at master · Vagr9K/gatsby-material-starter です。
以下、変更削除します。
まず、変更点ですが、 ここにも 横幅の 指定箇所が ありますので、 md-cell--9
指定をmd-cell--12
に変更します。 <div className={`md-grid md-cell--9 post-page-contents mobile-fix ${postOverlapClass}`}>
削除する<div className={`md-grid md-cell--12 post-page-contents mobile-fix ${postOverlapClass}`}>
箇所は、 Discus の comment 表示欄です。 以下記述を 削除します。 <Disqus postNode={postNode} expanded={expanded} />
4. robots.txt の 修正
robots.txt の
gatsby-material-starter/robots.txt at master · Vagr9K/gatsby-material-starter
User-agent: * Disallow: */tags/ Disallow: */categories/ sitemap: https://kemsakurai.github.io/sitemap.xml
その他、 サイト&コンテンツ作成時に 気づいたこと、 実施した こと
その他、
Google Search Console の 所有権の 確認
Google Search Console の
気長に
Markdown に link記載する 際、 同一ドメインの 且つ、 gastby の 管理外だと 上手く 遷移が できない
github.io の
kemsakurai.github.io/resources/html at master · kemsakurai/kemsakurai.github.io
htmlの
Gatsby Material Starter
[2] ページTop に
[Grid Layout](/resources/html/grid_export.html)
markdown から
<a href="/resources/html/grid_export.html" rel="noreferrer noopener" target="_blank">Grid Layout</a>
Bitbucket から、 Github Page への デプロイ
ここは、
rsync で
#!/bin/sh # github io のディレクトリ GITHUB_IO_DIR="your_local_github.io_dir" rsync -av --delete \ --exclude maven \ --exclude .git \ --exclude .DS_Store \ --exclude .gitignore \ --exclude resources \ --exclude cooperation \ --exclude google5056b155210a3bd8.html \ public/ $GITHUB_IO_DIR
.DS_Store
がrsync は、
--delete
を初回、
n
オプションを今後実施したいこと
gatsby を
kemsakurai.github.io document を
以上です。
コメント