{"componentChunkName":"component---src-templates-post-template-js","path":"/note-how-to-deploy-gatsby-spa-en","result":{"data":{"markdownRemark":{"id":"993488a2-a161-5376-afad-548c87066abb","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/note-how-to-deploy-gatsby-spa\">original page</a>.</p>\n</blockquote>\n<p>This may come as a surprise, but for various reasons I decided to move my blog.</p>\n<p>I plan to gradually migrate articles from my <a href=\"https://yukituna.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">old blog</a> to this one (it is a hassle because I have to do it manually…).</p>\n<p>For the new blog, I used the MIT-licensed Gatsby template <a href=\"https://github.com/alxshelepenok/gatsby-starter-lumen\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">gatsby-starter-lumen</a> as the base.</p>\n<p>In this article, I am recording the work I carried out before publishing the new blog as personal notes.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of Contents</h2>\n<ul>\n<li>\n<p><a href=\"#the-environment-built-in-this-article\">The Environment Built in This Article</a></p>\n<ul>\n<li><a href=\"#local-development-environment\">Local Development Environment</a></li>\n<li><a href=\"#deployment-environment\">Deployment Environment</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#build-the-gatsby-environment\">Build the Gatsby Environment</a></p>\n<ul>\n<li><a href=\"#install-docker\">Install Docker</a></li>\n<li><a href=\"#create-a-container-for-gatsby-development\">Create a Container for Gatsby Development</a></li>\n<li><a href=\"#create-the-gatsby-blog\">Create the Gatsby Blog</a></li>\n<li><a href=\"#troubleshooting-eacces-permission-error-for-appnpmsentry-cli\">Troubleshooting: <code class=\"language-text\">EACCES</code> Permission Error for <code class=\"language-text\">/app/.npm/sentry-cli</code></a></li>\n<li><a href=\"#troubleshooting-socialimage-error\">Troubleshooting: <code class=\"language-text\">socialImage</code> Error</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#change-the-gatsby-settings\">Change the Gatsby Settings</a></p>\n<ul>\n<li><a href=\"#change-the-profile-settings\">Change the Profile Settings</a></li>\n<li><a href=\"#site-design-settings\">Site Design Settings</a></li>\n<li><a href=\"#add-and-edit-content\">Add and Edit Content</a></li>\n<li><a href=\"#remove-the-directory-name-from-article-urls\">Remove the Directory Name from Article URLs</a></li>\n<li><a href=\"#change-the-syntax-highlighting-settings\">Change the Syntax Highlighting Settings</a></li>\n</ul>\n</li>\n<li><a href=\"#configure-typora\">Configure Typora</a></li>\n<li>\n<p><a href=\"#deploy-to-github-pages\">Deploy to GitHub Pages</a></p>\n<ul>\n<li><a href=\"#path-settings\">Path Settings</a></li>\n<li><a href=\"#create-a-custom-deployment-script\">Create a Custom Deployment Script</a></li>\n<li><a href=\"#pages-settings\">Pages Settings</a></li>\n</ul>\n</li>\n<li><a href=\"#summary\">Summary</a></li>\n</ul>\n<h2 id=\"the-environment-built-in-this-article\" style=\"position:relative;\"><a href=\"#the-environment-built-in-this-article\" aria-label=\"the environment built in this article permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The Environment Built in This Article</h2>\n<p>This time I am assuming the following environment.</p>\n<h3 id=\"local-development-environment\" style=\"position:relative;\"><a href=\"#local-development-environment\" aria-label=\"local development environment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Local Development Environment</h3>\n<ul>\n<li>Windows 10 Pro</li>\n<li>Docker</li>\n<li>Typora</li>\n</ul>\n<p>This will be the environment actually used to write articles.</p>\n<p>Markdown will be edited in Typora on the Windows host, and behavior will be checked in a Docker container where the Gatsby environment has been built.</p>\n<p>By the way, Typora is a highly capable Markdown editor.</p>\n<p>It recently became paid software, but it is a one-time license of about $15, so I highly recommend it.</p>\n<p>Reference: <a href=\"https://typora.io/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Typora</a></p>\n<h3 id=\"deployment-environment\" style=\"position:relative;\"><a href=\"#deployment-environment\" aria-label=\"deployment environment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Deployment Environment</h3>\n<p>The blog created locally will be deployed and published on GitHub Pages.</p>\n<p>It will also be configured so that it can be published using a custom domain.</p>\n<h2 id=\"build-the-gatsby-environment\" style=\"position:relative;\"><a href=\"#build-the-gatsby-environment\" aria-label=\"build the gatsby environment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Build the Gatsby Environment</h2>\n<h3 id=\"install-docker\" style=\"position:relative;\"><a href=\"#install-docker\" aria-label=\"install docker permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Install Docker</h3>\n<p>Currently, I think there are two main ways to install Docker on Windows:</p>\n<ul>\n<li>Install Docker on WSL2</li>\n<li>Install Docker Desktop for Windows</li>\n</ul>\n<p>Reference: <a href=\"https://docs.docker.com/desktop/windows/install/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Install Docker Desktop on Windows | Docker Documentation</a></p>\n<p>This time I planned to run Docker commands from PowerShell, so I installed Docker Desktop for Windows.</p>\n<p>Incidentally, Docker Desktop for Windows became a topic of discussion a little while ago when its license became paid, but it is still free for personal use.</p>\n<p>As for the installation method, it is enough to run the installer downloaded from the link in the documentation above.</p>\n<h3 id=\"create-a-container-for-gatsby-development\" style=\"position:relative;\"><a href=\"#create-a-container-for-gatsby-development\" aria-label=\"create a container for gatsby development permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create a Container for Gatsby Development</h3>\n<p>Next, build the Gatsby development environment.</p>\n<p>I basically referred to the following documentation and created a Dockerfile like this.</p>\n<p>Reference: <a href=\"https://www.gatsbyjs.com/docs/tutorial/part-0/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Part 0: Set Up Your Development Environment | Gatsby</a></p>\n<div class=\"gatsby-highlight\" data-language=\"dockerfile\"><pre class=\"language-dockerfile\"><code class=\"language-dockerfile\"><span class=\"token instruction\"><span class=\"token keyword\">FROM</span> ubuntu:20.04</span>\n<span class=\"token instruction\"><span class=\"token keyword\">ENV</span> TZ=Asia/Tokyo</span>\n\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> mkdir -p /app/blog</span>\n<span class=\"token instruction\"><span class=\"token keyword\">ENV</span> HOME=/app/</span>\n<span class=\"token instruction\"><span class=\"token keyword\">WORKDIR</span> /app</span>\n\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt update &amp;&amp; apt upgrade -y</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt install tzdata -y</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt install curl git python wget -y</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt install nodejs npm -y</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> npm install n -g</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> n stable</span>\n\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt purge -y nodejs npm</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> apt autoremove -y</span>\n\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> node -v</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> npm install -g gatsby-cli</span>\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> npm install gh-pages --save-dev</span>\n\n<span class=\"token instruction\"><span class=\"token keyword\">RUN</span> chown root:root ./* -R</span>\n<span class=\"token instruction\"><span class=\"token keyword\">WORKDIR</span> <span class=\"token variable\">$HOME</span>/blog</span>\n<span class=\"token instruction\"><span class=\"token keyword\">EXPOSE</span> 8000</span></code></pre></div>\n<p>After installing the latest NodeJS on top of an Ubuntu 20.04 container, I installed <code class=\"language-text\">gatsby-cli</code>.</p>\n<p>This makes the <code class=\"language-text\">gatsby</code> command available.</p>\n<p>Also, <code class=\"language-text\">gh-pages</code> is the package used when deploying to GitHub Pages.</p>\n<p>I will describe the details later.</p>\n<p>The image I created this time is published as <a href=\"https://hub.docker.com/repository/docker/kashiwabayuki/gatsby-env\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">kashiwabayuki/gatsby-env</a>, so you can also pull it with the following command.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> pull kashiwabayuki/gatsby-env</code></pre></div>\n<h3 id=\"create-the-gatsby-blog\" style=\"position:relative;\"><a href=\"#create-the-gatsby-blog\" aria-label=\"create the gatsby blog permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create the Gatsby Blog</h3>\n<p>After creating the container image, you need to log in to the container and perform some setup only when setting up the environment.</p>\n<p>In a PowerShell environment, you can log in to the container with the following command.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\"><span class=\"token variable\">$pwddir</span> = <span class=\"token punctuation\">(</span><span class=\"token function\">Get-Location</span> <span class=\"token operator\">-</span>PSProvider FileSystem<span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>Path\ndocker run <span class=\"token operator\">-</span>it <span class=\"token operator\">--</span><span class=\"token function\">rm</span> <span class=\"token operator\">--</span>volume <span class=\"token variable\">$pwddir</span><span class=\"token operator\">/</span>src:<span class=\"token operator\">/</span>app <span class=\"token operator\">-</span>p 8000:8000 kashiwabayuki/gatsby-env</code></pre></div>\n<p>With this command, I log in while mapping the local volume <code class=\"language-text\">src/</code> to the container’s home directory, <code class=\"language-text\">/app</code>.</p>\n<p>After logging in, create the Gatsby content with <code class=\"language-text\">gatsby-starter-lumen</code> using the following command.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">gatsby new blog https://github.com/alxshelepenok/gatsby-starter-lumen</code></pre></div>\n<p>Next, run the following command under the newly generated <code class=\"language-text\">blog</code> directory.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span>\n<span class=\"token comment\"># If this causes an error, run npm install --legacy-peer-deps.</span></code></pre></div>\n<p>If the <code class=\"language-text\">npm install</code> command fails, it is a good idea to try again with the <code class=\"language-text\">--legacy-peer-deps</code> option.</p>\n<p>This completes the initial blog setup.</p>\n<p>If the local server starts when you run the following command, you are done.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">gatsby develop -H <span class=\"token number\">0.0</span>.0.0</code></pre></div>\n<h3 id=\"troubleshooting-eacces-permission-error-for-appnpmsentry-cli\" style=\"position:relative;\"><a href=\"#troubleshooting-eacces-permission-error-for-appnpmsentry-cli\" aria-label=\"troubleshooting eacces permission error for appnpmsentry cli permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Troubleshooting: <code class=\"language-text\">EACCES</code> Permission Error for <code class=\"language-text\">/app/.npm/sentry-cli</code></h3>\n<p>The exact conditions are inconsistent so I am not sure of the cause, but when running <code class=\"language-text\">npm install</code>, a permission error such as <code class=\"language-text\">EACCES: permission denied, mkdir '/app/.npm/sentry-cli'</code> may occur.</p>\n<p>Because the Docker user is root, I would not normally expect this to happen, but it occurred several times in my environment.</p>\n<p>As a workaround, I was able to resolve it by explicitly setting the owner to root for the directory where the error occurs in the Dockerfile, like this.</p>\n<div class=\"gatsby-highlight\" data-language=\"dockerfile\"><pre class=\"language-dockerfile\"><code class=\"language-dockerfile\"><span class=\"token instruction\"><span class=\"token keyword\">RUN</span> chown root:root ./* -R</span></code></pre></div>\n<p>Sometimes the error does not occur at all, so honestly I still do not know the cause…</p>\n<h3 id=\"troubleshooting-socialimage-error\" style=\"position:relative;\"><a href=\"#troubleshooting-socialimage-error\" aria-label=\"troubleshooting socialimage error permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Troubleshooting: <code class=\"language-text\">socialImage</code> Error</h3>\n<p>Incidentally, you may see an error like the following at this point.</p>\n<p>It seems to occur when the value of <code class=\"language-text\">socialImage</code> for each article is empty, when the target image does not exist, or when the <code class=\"language-text\">static</code> directory cannot be resolved.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">Field <span class=\"token string\">\"socialImage\"</span> must not have a selection since <span class=\"token builtin class-name\">type</span> <span class=\"token string\">\"String\"</span> has no subfields.</code></pre></div>\n<p>The procedure in this article does not have that problem, but if you run <code class=\"language-text\">gatsby develop</code> on a Windows host, you may encounter this issue because of a known problem where the <code class=\"language-text\">static</code> directory cannot be resolved.</p>\n<p>To fix it, try the workaround described in the following issue, or use the container image described in this article.</p>\n<p>Reference: <a href=\"https://github.com/alxshelepenok/gatsby-starter-lumen/issues/761\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Field “socialImage” must not have a selection since type “String” has no subfields. · Issue #761 · alxshelepenok/gatsby-starter-lumen</a></p>\n<h2 id=\"change-the-gatsby-settings\" style=\"position:relative;\"><a href=\"#change-the-gatsby-settings\" aria-label=\"change the gatsby settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Change the Gatsby Settings</h2>\n<p>At this point, the minimum Gatsby environment is in place, so next I will do the initial setup.</p>\n<h3 id=\"change-the-profile-settings\" style=\"position:relative;\"><a href=\"#change-the-profile-settings\" aria-label=\"change the profile settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Change the Profile Settings</h3>\n<p>Basic profile and SNS settings can be changed in <code class=\"language-text\">blog/config.js</code>.</p>\n<p>The actual settings look like this.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token string\">'use strict'</span><span class=\"token punctuation\">;</span>\n\nmodule<span class=\"token punctuation\">.</span>exports <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">url</span><span class=\"token operator\">:</span> <span class=\"token string\">'https://kashiwaba-yuki.com'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">pathPrefix</span><span class=\"token operator\">:</span> <span class=\"token string\">'/'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> <span class=\"token string\">'Kaeru no Himitsukichi'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">subtitle</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">copyright</span><span class=\"token operator\">:</span> <span class=\"token string\">'All rights reserved 2022 Kaeru-no-Himitsukichi.'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">disqusShortname</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">postsPerPage</span><span class=\"token operator\">:</span> <span class=\"token number\">4</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">googleAnalyticsId</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">useKatex</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">menu</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">label</span><span class=\"token operator\">:</span> <span class=\"token string\">'All Articles'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/'</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">label</span><span class=\"token operator\">:</span> <span class=\"token string\">'Development'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/tag/development'</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">label</span><span class=\"token operator\">:</span> <span class=\"token string\">'Notes'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/category/note'</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">author</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'Kashiwaba'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">photo</span><span class=\"token operator\">:</span> <span class=\"token string\">'/avatar.png'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">bio</span><span class=\"token operator\">:</span> <span class=\"token string\">'A hobby programmer who wants to become a reverse engineer.'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">contacts</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">email</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">facebook</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">telegram</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">twitter</span><span class=\"token operator\">:</span> <span class=\"token string\">'yuki_kashiwaba'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">github</span><span class=\"token operator\">:</span> <span class=\"token string\">'kash1064'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">rss</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">vkontakte</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">linkedin</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">instagram</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">line</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">gitlab</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">weibo</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">codepen</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">youtube</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">soundcloud</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">medium</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">,</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>In particular, for SNS accounts under <code class=\"language-text\">contacts</code>, items you do not want to display must be left blank rather than commented out.</p>\n<p>If you comment them out, an error occurs.</p>\n<h3 id=\"site-design-settings\" style=\"position:relative;\"><a href=\"#site-design-settings\" aria-label=\"site design settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Site Design Settings</h3>\n<p>If you want to change the site design, you need to edit the template for each element.</p>\n<p>This time I did not change the base layout, and only changed some colors and similar settings.</p>\n<p>If you want to change the base design, edit <code class=\"language-text\">blog/src/assets/scss/base/_generic.scss</code>.</p>\n<p>The contents look like this, and you can change text size, colors, fonts, and so on for each element.</p>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre class=\"language-css\"><code class=\"language-css\"><span class=\"token comment\">/** \n * Generic\n */</span>\n<span class=\"token selector\">html</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span> $typographic-root-font-size<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\">body</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">margin</span><span class=\"token punctuation\">:</span> 0 0 0 <span class=\"token function\">calc</span><span class=\"token punctuation\">(</span>100vw - 100%<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token property\">font-family</span><span class=\"token punctuation\">:</span> $typographic-font-family<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">color</span><span class=\"token punctuation\">:</span> $typographic-base-font-color<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">line-height</span><span class=\"token punctuation\">:</span> $typographic-base-line-height<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span> $typographic-base-font-size<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">-ms-text-size-adjust</span><span class=\"token punctuation\">:</span> 100%<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">-webkit-text-size-adjust</span><span class=\"token punctuation\">:</span> 100%<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">text-rendering</span><span class=\"token punctuation\">:</span> optimizeLegibility<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">-webkit-font-smoothing</span><span class=\"token punctuation\">:</span> antialiased<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">-moz-osx-font-smoothing</span><span class=\"token punctuation\">:</span> grayscale<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\">h1,\nh2,\nh3,\nh4,\nh5,\nh6</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">font-family</span><span class=\"token punctuation\">:</span> $typographic-font-family<span class=\"token punctuation\">;</span>\n  <span class=\"token property\">font-weight</span><span class=\"token punctuation\">:</span> 600<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\">h1</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span> $typographic-base-font-size * 1.8<span class=\"token punctuation\">;</span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">line-height</span><span class=\"token punctuation\">(</span>1.8<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-top</span><span class=\"token punctuation\">(</span>4<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-bottom</span><span class=\"token punctuation\">(</span>1<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\">h2</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span> $typographic-base-font-size * 1.6875<span class=\"token punctuation\">;</span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">line-height</span><span class=\"token punctuation\">(</span>1.5<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-top</span><span class=\"token punctuation\">(</span>2<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-bottom</span><span class=\"token punctuation\">(</span>.5<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\">h3</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span> $typographic-base-font-size * 1.375<span class=\"token punctuation\">;</span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">line-height</span><span class=\"token punctuation\">(</span>1<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-top</span><span class=\"token punctuation\">(</span>2<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n  <span class=\"token atrule\"><span class=\"token rule\">@include</span> <span class=\"token function\">margin-bottom</span><span class=\"token punctuation\">(</span>.5<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> omitted <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span></code></pre></div>\n<p>Also, the link colors and the sizes of some elements are configured by the variables defined in <code class=\"language-text\">blog/src/assets/scss/_variables.scss</code>.</p>\n<p>For example, if you want to change the link color, you need to change <code class=\"language-text\">$color-primary</code>.</p>\n<p>The maximum content width is set by <code class=\"language-text\">$layout-post-single-width</code>.</p>\n<p>For that reason, I also changed some of the base colors on my blog as follows.</p>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre class=\"language-css\"><code class=\"language-css\">// Colors\n$<span class=\"token property\">color-base</span><span class=\"token punctuation\">:</span> #222<span class=\"token punctuation\">;</span>\n$<span class=\"token property\">color-primary</span><span class=\"token punctuation\">:</span> #918D40<span class=\"token punctuation\">;</span>\n$<span class=\"token property\">color-secondary</span><span class=\"token punctuation\">:</span> #A9D159<span class=\"token punctuation\">;</span>\n\n$<span class=\"token property\">color-white</span><span class=\"token punctuation\">:</span> #FFF<span class=\"token punctuation\">;</span>\n$<span class=\"token property\">color-gray</span><span class=\"token punctuation\">:</span> <span class=\"token function\">lighten</span><span class=\"token punctuation\">(</span>$color-base<span class=\"token punctuation\">,</span> 40%<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n$<span class=\"token property\">color-gray-border</span><span class=\"token punctuation\">:</span> <span class=\"token function\">lighten</span><span class=\"token punctuation\">(</span>$color-base<span class=\"token punctuation\">,</span> 77%<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n$<span class=\"token property\">color-gray-bg</span><span class=\"token punctuation\">:</span> <span class=\"token function\">lighten</span><span class=\"token punctuation\">(</span>$color-base<span class=\"token punctuation\">,</span> 79%<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<h3 id=\"add-and-edit-content\" style=\"position:relative;\"><a href=\"#add-and-edit-content\" aria-label=\"add and edit content permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add and Edit Content</h3>\n<p>When you use <code class=\"language-text\">gatsby-starter-lumen</code>, two content types are prepared by default.</p>\n<ul>\n<li>Pages: Fixed pages such as the About page</li>\n<li>Posts: Blog content</li>\n</ul>\n<p>Both are placed under the <code class=\"language-text\">blog/content/</code> directory.</p>\n<p>Gatsby searches the files under <code class=\"language-text\">blog/content/</code> according to the definitions in <code class=\"language-text\">blog/src/cms/index.js</code> and identifies them as pages of the specified format.</p>\n<p>For that reason, by default all blog pages must be placed under <code class=\"language-text\">blog/content/posts</code>, but if you want to add a custom directory such as <code class=\"language-text\">notes</code> here, you need to associate the directory name with a template in <code class=\"language-text\">CMS.registerPreviewTemplate</code> as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token comment\">// @flow strict</span>\n<span class=\"token keyword\">import</span> <span class=\"token constant\">CMS</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'netlify-cms-app'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> PagePreview <span class=\"token keyword\">from</span> <span class=\"token string\">'./preview-templates/page-preview'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> PostPreview <span class=\"token keyword\">from</span> <span class=\"token string\">'./preview-templates/post-preview'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token constant\">CMS</span><span class=\"token punctuation\">.</span><span class=\"token function\">registerPreviewTemplate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'pages'</span><span class=\"token punctuation\">,</span> PagePreview<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token constant\">CMS</span><span class=\"token punctuation\">.</span><span class=\"token function\">registerPreviewTemplate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'posts'</span><span class=\"token punctuation\">,</span> PostPreview<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token constant\">CMS</span><span class=\"token punctuation\">.</span><span class=\"token function\">registerPreviewTemplate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'notes'</span><span class=\"token punctuation\">,</span> PostPreview<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<h3 id=\"remove-the-directory-name-from-article-urls\" style=\"position:relative;\"><a href=\"#remove-the-directory-name-from-article-urls\" aria-label=\"remove the directory name from article urls permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Remove the Directory Name from Article URLs</h3>\n<p>By default, article URLs are in the following format.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">https://<span class=\"token operator\">&lt;</span>custom-domain<span class=\"token operator\">></span>/<span class=\"token operator\">&lt;</span>directory-name-containing-the-article<span class=\"token operator\">></span>/<span class=\"token operator\">&lt;</span>article-slug<span class=\"token operator\">></span></code></pre></div>\n<p>If <code class=\"language-text\">&lt;directory-name-containing-the-article></code> is embedded in the URL, the URL will change every time you move the Markdown file to a different directory in the future, which is not desirable.</p>\n<p>So I change the settings so that <code class=\"language-text\">&lt;directory-name-containing-the-article></code> is not included in the URL.</p>\n<p>Rewrite <code class=\"language-text\">createNodeField</code> in <code class=\"language-text\">blog/gatsby/on-create-node.js</code> as follows.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>node<span class=\"token punctuation\">.</span>internal<span class=\"token punctuation\">.</span>type <span class=\"token operator\">===</span> <span class=\"token string\">'MarkdownRemark'</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">typeof</span> node<span class=\"token punctuation\">.</span>frontmatter<span class=\"token punctuation\">.</span>slug <span class=\"token operator\">!==</span> <span class=\"token string\">'undefined'</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">const</span> dirname <span class=\"token operator\">=</span> <span class=\"token function\">getNode</span><span class=\"token punctuation\">(</span>node<span class=\"token punctuation\">.</span>parent<span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>relativeDirectory<span class=\"token punctuation\">;</span>\n    <span class=\"token function\">createNodeField</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n      node<span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'slug'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token comment\">// value: `/${dirname}/${node.frontmatter.slug}`</span>\n      <span class=\"token literal-property property\">value</span><span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">/</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>node<span class=\"token punctuation\">.</span>frontmatter<span class=\"token punctuation\">.</span>slug<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>This removes the directory name from the URLs generated at deploy time.</p>\n<h3 id=\"change-the-syntax-highlighting-settings\" style=\"position:relative;\"><a href=\"#change-the-syntax-highlighting-settings\" aria-label=\"change the syntax highlighting settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Change the Syntax Highlighting Settings</h3>\n<p>The syntax highlighting in the theme used this time uses Prism.js.</p>\n<p>Therefore, if you want to customize the syntax highlighting, you need to generate CSS from the following page and replace <code class=\"language-text\">static\\css\\prismjs\\theme.min.css</code>.</p>\n<p>Reference: <a href=\"https://prismjs.com/download.html#themes=prism-tomorrow&#x26;languages=markup+css+clike+javascript\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Download ▲ Prism</a></p>\n<p>Incidentally, my blog uses the following configuration.</p>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre class=\"language-css\"><code class=\"language-css\"><span class=\"token comment\">/* PrismJS 1.27.0\nhttps://prismjs.com/download.html#themes=prism-tomorrow&amp;languages=markup+css+clike+javascript+aspnet+bash+c+csharp+cpp+csv+dart+django+go+http+java+makefile+markdown+markup-templating+nginx+php+powershell+python+ruby+rust+sql+typescript+yaml */</span>\n<span class=\"token selector\">code[class*=language-],pre[class*=language-]</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#ccc<span class=\"token punctuation\">;</span><span class=\"token property\">background</span><span class=\"token punctuation\">:</span>0 0<span class=\"token punctuation\">;</span><span class=\"token property\">font-family</span><span class=\"token punctuation\">:</span>Consolas<span class=\"token punctuation\">,</span>Monaco<span class=\"token punctuation\">,</span><span class=\"token string\">'Andale Mono'</span><span class=\"token punctuation\">,</span><span class=\"token string\">'Ubuntu Mono'</span><span class=\"token punctuation\">,</span>monospace<span class=\"token punctuation\">;</span><span class=\"token property\">font-size</span><span class=\"token punctuation\">:</span>1em<span class=\"token punctuation\">;</span><span class=\"token property\">text-align</span><span class=\"token punctuation\">:</span>left<span class=\"token punctuation\">;</span><span class=\"token property\">white-space</span><span class=\"token punctuation\">:</span>pre<span class=\"token punctuation\">;</span><span class=\"token property\">word-spacing</span><span class=\"token punctuation\">:</span>normal<span class=\"token punctuation\">;</span><span class=\"token property\">word-break</span><span class=\"token punctuation\">:</span>normal<span class=\"token punctuation\">;</span><span class=\"token property\">word-wrap</span><span class=\"token punctuation\">:</span>normal<span class=\"token punctuation\">;</span><span class=\"token property\">line-height</span><span class=\"token punctuation\">:</span>1.5<span class=\"token punctuation\">;</span><span class=\"token property\">-moz-tab-size</span><span class=\"token punctuation\">:</span>4<span class=\"token punctuation\">;</span><span class=\"token property\">-o-tab-size</span><span class=\"token punctuation\">:</span>4<span class=\"token punctuation\">;</span><span class=\"token property\">tab-size</span><span class=\"token punctuation\">:</span>4<span class=\"token punctuation\">;</span><span class=\"token property\">-webkit-hyphens</span><span class=\"token punctuation\">:</span>none<span class=\"token punctuation\">;</span><span class=\"token property\">-moz-hyphens</span><span class=\"token punctuation\">:</span>none<span class=\"token punctuation\">;</span><span class=\"token property\">-ms-hyphens</span><span class=\"token punctuation\">:</span>none<span class=\"token punctuation\">;</span><span class=\"token property\">hyphens</span><span class=\"token punctuation\">:</span>none<span class=\"token punctuation\">}</span><span class=\"token selector\">pre[class*=language-]</span><span class=\"token punctuation\">{</span><span class=\"token property\">padding</span><span class=\"token punctuation\">:</span>1em<span class=\"token punctuation\">;</span><span class=\"token property\">margin</span><span class=\"token punctuation\">:</span>.5em 0<span class=\"token punctuation\">;</span><span class=\"token property\">overflow</span><span class=\"token punctuation\">:</span>auto<span class=\"token punctuation\">}</span><span class=\"token selector\">:not(pre)>code[class*=language-],pre[class*=language-]</span><span class=\"token punctuation\">{</span><span class=\"token property\">background</span><span class=\"token punctuation\">:</span>#2d2d2d<span class=\"token punctuation\">}</span><span class=\"token selector\">:not(pre)>code[class*=language-]</span><span class=\"token punctuation\">{</span><span class=\"token property\">padding</span><span class=\"token punctuation\">:</span>.1em<span class=\"token punctuation\">;</span><span class=\"token property\">border-radius</span><span class=\"token punctuation\">:</span>.3em<span class=\"token punctuation\">;</span><span class=\"token property\">white-space</span><span class=\"token punctuation\">:</span>normal<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#999<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.punctuation</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#ccc<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.attr-name,.token.deleted,.token.namespace,.token.tag</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#e2777a<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.function-name</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#6196cc<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.boolean,.token.function,.token.number</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#f08d49<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.class-name,.token.constant,.token.property,.token.symbol</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#f8c555<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#cc99cd<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.attr-value,.token.char,.token.regex,.token.string,.token.variable</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#7ec699<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.entity,.token.operator,.token.url</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>#67cdcc<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.bold,.token.important</span><span class=\"token punctuation\">{</span><span class=\"token property\">font-weight</span><span class=\"token punctuation\">:</span>700<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.italic</span><span class=\"token punctuation\">{</span><span class=\"token property\">font-style</span><span class=\"token punctuation\">:</span>italic<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.entity</span><span class=\"token punctuation\">{</span><span class=\"token property\">cursor</span><span class=\"token punctuation\">:</span>help<span class=\"token punctuation\">}</span><span class=\"token selector\">.token.inserted</span><span class=\"token punctuation\">{</span><span class=\"token property\">color</span><span class=\"token punctuation\">:</span>green<span class=\"token punctuation\">}</span>\n\n<span class=\"token selector\"># Update\np > code[class*=language-text]</span><span class=\"token punctuation\">{</span><span class=\"token property\">background</span><span class=\"token punctuation\">:</span>#F9F9F9 <span class=\"token important\">!important</span><span class=\"token punctuation\">;</span> <span class=\"token property\">color</span><span class=\"token punctuation\">:</span> #2d2d2d <span class=\"token important\">!important</span><span class=\"token punctuation\">;</span><span class=\"token punctuation\">}</span>\n<span class=\"token selector\">li > code[class*=language-text]</span><span class=\"token punctuation\">{</span><span class=\"token property\">background</span><span class=\"token punctuation\">:</span>#F9F9F9 <span class=\"token important\">!important</span><span class=\"token punctuation\">;</span> <span class=\"token property\">color</span><span class=\"token punctuation\">:</span> #2d2d2d <span class=\"token important\">!important</span><span class=\"token punctuation\">;</span><span class=\"token punctuation\">}</span></code></pre></div>\n<p>The last line defines the background color and text color for inline preformatted text embedded in the body.</p>\n<h2 id=\"configure-typora\" style=\"position:relative;\"><a href=\"#configure-typora\" aria-label=\"configure typora permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure Typora</h2>\n<p>One very useful feature of the Markdown editor Typora, which I use all the time, is that when you copy and paste images it automatically saves them to a local folder of your choice.</p>\n<p>With Gatsby, images under <code class=\"language-text\">blog/static/media</code> can be accessed via <code class=\"language-text\">/media</code>.</p>\n<p>So in Typora I configured it as follows so that pasted images are placed in any directory under <code class=\"language-text\">blog/static/media</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/915fae9fa8c5853d16b68d568fce6fff/525d3/image-20220221222611109.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 47.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABWklEQVQoz42S3VKDMBCFeaZaAuEnQKAhtKZYtZ3q2AsvHX3/2+NuWiJ16owX3wQ27Nmzu0RxViHOa8QZU3nu0tKfIq9C7L9EIlOIJQsoEjiLVp1FWjRB2CNVQNwQ4lwmSrICIs2RyCIIWrdDqQ3yqkNaagjVQugeyYUlvXN8TnDILjxc/RKUVYuMxBQlC/rYlQ0+V2t8rUd80HlIcii6LxqDol5RRwMas0FCXUWdHaGNQ91tgsOJJRVZEEat8Ebix7rDK3GiZGMdFAnp/p6Ee2+AnUb74zse9ye43dFXmM9D5A0EjWJhXqBGYthCrXfoxgMKbn3WVWhZ0jwW1MLPZuvglE+Oa/uAYfsMM4wY3BMaapsdTQbmi4muHV2LcQK7qGnrune0KHuhBxvh+wmfyzOcC0zPhobPm+ahs2BatihbGwpwXM42LRl6P/+HN9xNH0+Ffrf110/Nd9//6Vjt6iNuBQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/915fae9fa8c5853d16b68d568fce6fff/8ac56/image-20220221222611109.webp 240w,\n/static/915fae9fa8c5853d16b68d568fce6fff/d3be9/image-20220221222611109.webp 480w,\n/static/915fae9fa8c5853d16b68d568fce6fff/e46b2/image-20220221222611109.webp 960w,\n/static/915fae9fa8c5853d16b68d568fce6fff/36bbb/image-20220221222611109.webp 1090w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/915fae9fa8c5853d16b68d568fce6fff/8ff5a/image-20220221222611109.png 240w,\n/static/915fae9fa8c5853d16b68d568fce6fff/e85cb/image-20220221222611109.png 480w,\n/static/915fae9fa8c5853d16b68d568fce6fff/d9199/image-20220221222611109.png 960w,\n/static/915fae9fa8c5853d16b68d568fce6fff/525d3/image-20220221222611109.png 1090w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/915fae9fa8c5853d16b68d568fce6fff/d9199/image-20220221222611109.png\"\n            alt=\"image-20220221222611109\"\n            title=\"image-20220221222611109\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>This allows blog pages to reference the appropriate images after deployment.</p>\n<h2 id=\"deploy-to-github-pages\" style=\"position:relative;\"><a href=\"#deploy-to-github-pages\" aria-label=\"deploy to github pages permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Deploy to GitHub Pages</h2>\n<p>Now that the basic shape is in place, it is finally time to deploy.</p>\n<p>The procedure is basically based on the official instructions.</p>\n<p>Reference: <a href=\"https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/how-gatsby-works-with-github-pages/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">How Gatsby Works with GitHub Pages | Gatsby</a></p>\n<p>First, you need a GitHub repository for publishing.</p>\n<p>The repository needs to be public.</p>\n<p>Once the push to the public repository is complete, you can begin deploying to GitHub Pages.</p>\n<h3 id=\"path-settings\" style=\"position:relative;\"><a href=\"#path-settings\" aria-label=\"path settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Path Settings</h3>\n<p>This time I use a custom domain, so I set <code class=\"language-text\">/</code> in <code class=\"language-text\">pathPrefix</code> of <code class=\"language-text\">blog\\gatsby-config.js</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">module<span class=\"token punctuation\">.</span>exports <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token comment\">// pathPrefix: siteConfig.pathPrefix,</span>\n  <span class=\"token literal-property property\">pathPrefix</span><span class=\"token operator\">:</span> <span class=\"token string\">\"/\"</span><span class=\"token punctuation\">,</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>This setting is necessary so that the proper path is used when accessing the site by URL.</p>\n<p>On the other hand, if you do not specify a custom domain, set the repository name in <code class=\"language-text\">pathPrefix</code>.</p>\n<h3 id=\"create-a-custom-deployment-script\" style=\"position:relative;\"><a href=\"#create-a-custom-deployment-script\" aria-label=\"create a custom deployment script permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create a Custom Deployment Script</h3>\n<p>Next, configure the deployment script.</p>\n<p>Set <code class=\"language-text\">scripts>deploy</code> in <code class=\"language-text\">blog\\package.json</code> as follows.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token string-property property\">\"scripts\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    \n  <span class=\"token string-property property\">\"deploy\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"rm -rf node_modules/.cache/gh-pages &amp;&amp; gatsby clean &amp;&amp; gatsby build --prefix-paths &amp;&amp; echo 'kashiwaba-yuki.com' > public/CNAME &amp;&amp; gh-pages -d public -b pages\"</span><span class=\"token punctuation\">,</span>\n\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span></code></pre></div>\n<p><code class=\"language-text\">rm -rf node_modules/.cache/gh-pages</code> removes past cache so that errors do not occur during the build.</p>\n<p><code class=\"language-text\">gatsby clean &amp;&amp; gatsby build --prefix-paths</code> builds the content with the <code class=\"language-text\">gatsby</code> command.</p>\n<p><code class=\"language-text\">gatsby clean</code> is required to make sure your changes are reflected.</p>\n<p><code class=\"language-text\">echo 'kashiwaba-yuki.com' > public/CNAME</code> is used to place a CNAME file for using a custom domain in the public directory.</p>\n<p>Without this, the custom domain is removed every time you deploy.</p>\n<p><code class=\"language-text\">gh-pages -d public -b pages</code> uses <code class=\"language-text\">gh-pages</code> to place the built content in the <code class=\"language-text\">pages</code> branch.</p>\n<p>Because this pushes to a Git repository, you need to make sure you can push to the repository from inside the container.</p>\n<h3 id=\"pages-settings\" style=\"position:relative;\"><a href=\"#pages-settings\" aria-label=\"pages settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pages Settings</h3>\n<p>Once you get this far, the rest is easy.</p>\n<p>Open the settings screen of the public repository, and under “Pages” specify the publishing branch <code class=\"language-text\">pages</code> to publish with GitHub Pages.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/f563b163d6bd711d854562d48559456d/dcccd/image-20220223010848772.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 62.916666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAACDElEQVQ4y22Ty3LbMAxFtW0cvUVRoiTqLVuPpOOk6abLTL+gq35E/395C0C2x0m7OAMNRV5cgKATZxZuqIXHIJVobI+qmaCLDgdfEekF9V/cQN80nCgtRegqxqjqBG2PMFWPWFdQlFTlTI2ESIt2j6aRtes5EWyGFRkd9KKMMpFopBH0NbJlQvl0gtlmpOu2s8yIRxIlJE4NfTcIu1JwVQZHc7a7sllQNXTAVoiqCiERVJao6ZtiWcIvSnjGwMtzwadvxo3Joe1Od/1LxWlLrm07o7AjqvZEcPkDMkoeaws/bWlvjkfq6wdIwzF2EJH7PjbjhuP2Av5n+xklCXLfQhI7BJxcSfL73t16OM5fwWVHupTSg8SgOz5jfn5DQTfNlyYXQ80PdAMvqW7J7xFBdsgH/DhHqApxythuRjttJFbdNh8ukff6sUFA0SPcKBe3uzA57I5PyMpe3F0Pc4ksaKiHzTCjHlechgU99TPJ91FhQl3DU5/GJslqPHjJzYFHGctulXJDcs8tYKcJESlzN69cjf6nl05NmXlA94X9Z0DzlBZW1tl5chnomNzFZpD2ROmOH2cfLsnhoeZLuWb44oZ4//kHbz9+o11eMazfMa4vGJczhplYX1FPZ6SWXlM9X1joZU3SX0fK5fd4EXzwY5y//cK0vdOhI72iiRg+oGlNFQNUOe6RSEwrF/oXt29Oq5a0OpwAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/f563b163d6bd711d854562d48559456d/8ac56/image-20220223010848772.webp 240w,\n/static/f563b163d6bd711d854562d48559456d/d3be9/image-20220223010848772.webp 480w,\n/static/f563b163d6bd711d854562d48559456d/e46b2/image-20220223010848772.webp 960w,\n/static/f563b163d6bd711d854562d48559456d/0b154/image-20220223010848772.webp 1127w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/f563b163d6bd711d854562d48559456d/8ff5a/image-20220223010848772.png 240w,\n/static/f563b163d6bd711d854562d48559456d/e85cb/image-20220223010848772.png 480w,\n/static/f563b163d6bd711d854562d48559456d/d9199/image-20220223010848772.png 960w,\n/static/f563b163d6bd711d854562d48559456d/dcccd/image-20220223010848772.png 1127w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/f563b163d6bd711d854562d48559456d/d9199/image-20220223010848772.png\"\n            alt=\"image-20220223010848772\"\n            title=\"image-20220223010848772\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>This time I also created a CNAME file and enabled the custom domain, so you can check the blog you created by connecting to this domain.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>I plan to gradually migrate posts here from my old WordPress blog.</p>\n<p>It looks like it will take quite a bit of work because I need to manually fix things like images and internal links…</p>","fields":{"slug":"/note-how-to-deploy-gatsby-spa-en","tagSlugs":["/tag/blog/","/tag/gatsby/","/tag/memo/","/tag/english/"]},"frontmatter":{"date":"2022-02-20","description":"This article summarizes the steps for publishing a blog built with Gatsby to GitHub Pages. The Gatsby development environment is built in a Docker container.","tags":["Blog","Gatsby","Memo","English"],"title":"Notes on Setting Up an Environment to Publish a Gatsby SPA Blog on GitHub Pages","socialImage":{"publicURL":"/static/09d53d0b620280b69e0b4abe0fe4fbdd/note-how-to-deploy-gatsby-spa.png"}}}},"pageContext":{"slug":"/note-how-to-deploy-gatsby-spa-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}