<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Website on Blogs (码码要洗手)</title><link>https://navydev.top/blog/tags/website/</link><description>Recent content in Website on Blogs (码码要洗手)</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><lastBuildDate>Sun, 12 Mar 2023 15:44:12 +0800</lastBuildDate><atom:link href="https://navydev.top/blog/tags/website/index.xml" rel="self" type="application/rss+xml"/><item><title>How To Build This Website</title><link>https://navydev.top/blog/how-to-build-this-website/</link><pubDate>Sun, 12 Mar 2023 15:44:12 +0800</pubDate><guid>https://navydev.top/blog/how-to-build-this-website/</guid><description>&lt;img src="https://navydev.top/images/covers/how-to-build-this-website.webp" alt="Featured image of post How To Build This Website" /&gt;&lt;p&gt;This website is built with &lt;strong&gt;Hugo&lt;/strong&gt;, a static site generator, and hosted on &lt;strong&gt;GitHub Pages&lt;/strong&gt;. The deployment process is automated using &lt;strong&gt;GitHub Actions&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="workflow"&gt;Workflow
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Write&lt;/strong&gt;: I write blog posts in Markdown format in the &lt;code&gt;content&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Commit&lt;/strong&gt;: I commit the changes and push them to the GitHub repository.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deploy&lt;/strong&gt;: GitHub Actions detects the push, builds the Hugo site, and deploys the generated &lt;code&gt;public&lt;/code&gt; folder to the &lt;code&gt;gh-pages&lt;/code&gt; branch.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="prerequisites"&gt;Prerequisites
&lt;/h2&gt;&lt;p&gt;You need the following tools installed on your local machine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Git&lt;/strong&gt;: For version control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hugo&lt;/strong&gt;: For generating the static site.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitHub Account&lt;/strong&gt;: To host the repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="installation"&gt;Installation
&lt;/h3&gt;&lt;p&gt;On macOS, you can use Homebrew:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;brew install git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;brew install hugo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="setup-guide"&gt;Setup Guide
&lt;/h2&gt;&lt;h3 id="1-create-a-new-site"&gt;1. Create a New Site
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new site my-blog
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd my-blog
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git init
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="2-add-a-theme"&gt;2. Add a Theme
&lt;/h3&gt;&lt;p&gt;Add a theme (e.g., PaperMod) as a submodule:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;theme = &amp;#39;PaperMod&amp;#39;&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; hugo.toml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="3-create-content"&gt;3. Create Content
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new posts/my-first-post.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="4-run-locally"&gt;4. Run Locally
&lt;/h3&gt;&lt;p&gt;Start the local server with draft enabled:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo server -D
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Visit &lt;code&gt;http://localhost:1313&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="5-github-actions-configuration"&gt;5. GitHub Actions Configuration
&lt;/h3&gt;&lt;p&gt;Create &lt;code&gt;.github/workflows/hugo.yaml&lt;/code&gt; to automate deployment.
You can find the standard workflow in the &lt;a class="link" href="https://gohugo.io/hosting-and-deployment/hosting-on-github/" target="_blank" rel="noopener"
&gt;Hugo Hosting on GitHub Pages&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id="create-new-site-by-hugo"&gt;Create new site by Hugo
&lt;/h2&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;hugo new site wsgggws.github.io
cd wsgggws.github.io
git config --global init.defaultBranch main
git init
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="install-theme-paper"&gt;Install theme &lt;a class="link" href="https://www.producthunt.com/products/hugo-paper" target="_blank" rel="noopener"
&gt;paper&lt;/a&gt;
&lt;/h2&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;git submodule add https://github.com/nanxiaobei/hugo-paper themes/paper
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="create-a-new-posts"&gt;Create a new posts
&lt;/h2&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;hugo new content blogs/title.md
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="observing-locally-website"&gt;Observing locally website
&lt;/h2&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;hugo server
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="hosting-on-github"&gt;&lt;a class="link" href="https://gohugo.io/hosting-and-deployment/hosting-on-github/" target="_blank" rel="noopener"
&gt;Hosting on GitHub&lt;/a&gt;
&lt;/h2&gt;&lt;p&gt;Create a repo named {username}.github.io in GitHub&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# You should change wsgggws to your username
git remote add origin git@github.com:wsgggws/wsgggws.github.io.git
vim .github/workflows/hugo.yaml
git add .
git commit -m&amp;#34;Add github action for auto deploying&amp;#34;
git push -f -u origin main
# After GitHub action is done
open https://wsgggws.github.io
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="references"&gt;references
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://gohugo.io/hosting-and-deployment/hosting-on-github/" target="_blank" rel="noopener"
&gt;https://gohugo.io/hosting-and-deployment/hosting-on-github/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>