From 61d2b003a3b10e0eefd1eed4632b38d3bdfaae58 Mon Sep 17 00:00:00 2001 From: Jogisara Ramachandra Sandesh Bhat Date: Sun, 6 Oct 2024 14:19:00 +0200 Subject: [PATCH 1/5] Bootstrap a hugo website --- web/archetypes/default.md | 5 +++++ web/hugo.toml | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 web/archetypes/default.md create mode 100644 web/hugo.toml diff --git a/web/archetypes/default.md b/web/archetypes/default.md new file mode 100644 index 0000000..c6f3fce --- /dev/null +++ b/web/archetypes/default.md @@ -0,0 +1,5 @@ ++++ +title = '{{ replace .File.ContentBaseName "-" " " | title }}' +date = {{ .Date }} +draft = true ++++ diff --git a/web/hugo.toml b/web/hugo.toml new file mode 100644 index 0000000..7e568b8 --- /dev/null +++ b/web/hugo.toml @@ -0,0 +1,3 @@ +baseURL = 'https://example.org/' +languageCode = 'en-us' +title = 'My New Hugo Site' From bc766ed6be75ac3be893462baeb0e71e41717442 Mon Sep 17 00:00:00 2001 From: Jogisara Ramachandra Sandesh Bhat Date: Sun, 6 Oct 2024 14:21:50 +0200 Subject: [PATCH 2/5] Add the theme hugo-book https://themes.gohugo.io/themes/hugo-book/ --- web/go.mod | 5 +++++ web/go.sum | 2 ++ web/hugo.toml | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 web/go.mod create mode 100644 web/go.sum diff --git a/web/go.mod b/web/go.mod new file mode 100644 index 0000000..81faef5 --- /dev/null +++ b/web/go.mod @@ -0,0 +1,5 @@ +module github.com/repo/path + +go 1.22.5 + +require github.com/alex-shpak/hugo-book v0.0.0-20241004133543-21e7727a0e9f // indirect diff --git a/web/go.sum b/web/go.sum new file mode 100644 index 0000000..ee77ef5 --- /dev/null +++ b/web/go.sum @@ -0,0 +1,2 @@ +github.com/alex-shpak/hugo-book v0.0.0-20241004133543-21e7727a0e9f h1:IiSYEZsht58/ytrPgHT1Rz12wvf1GB1tX6UgZueYsRA= +github.com/alex-shpak/hugo-book v0.0.0-20241004133543-21e7727a0e9f/go.mod h1:L4NMyzbn15fpLIpmmtDg9ZFFyTZzw87/lk7M2bMQ7ds= diff --git a/web/hugo.toml b/web/hugo.toml index 7e568b8..79a31f4 100644 --- a/web/hugo.toml +++ b/web/hugo.toml @@ -1,3 +1,7 @@ baseURL = 'https://example.org/' languageCode = 'en-us' title = 'My New Hugo Site' + +[module] +[[module.imports]] +path = 'github.com/alex-shpak/hugo-book' \ No newline at end of file From 7238c51f417aac2c26c70216036daece3a3d0ef1 Mon Sep 17 00:00:00 2001 From: Jogisara Ramachandra Sandesh Bhat Date: Sun, 6 Oct 2024 14:25:19 +0200 Subject: [PATCH 3/5] Ignore hugo generated files --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd5d899 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +### Hugo ### + +# Generated files by hugo +*/public/* +*/resources/_gen/ + +# Temporary lock file while building +.hugo_build.lock \ No newline at end of file From e78f99e41b9fcc6a05cdea0b5e26a4297762ce7e Mon Sep 17 00:00:00 2001 From: Jogisara Ramachandra Sandesh Bhat Date: Sun, 6 Oct 2024 14:26:11 +0200 Subject: [PATCH 4/5] Change title --- web/hugo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/hugo.toml b/web/hugo.toml index 79a31f4..c24739f 100644 --- a/web/hugo.toml +++ b/web/hugo.toml @@ -1,6 +1,6 @@ baseURL = 'https://example.org/' languageCode = 'en-us' -title = 'My New Hugo Site' +title = 'sandeshbhatjr/notes' [module] [[module.imports]] From cc74b870ddd1b0926a771d413cdf865c3f3d5cfe Mon Sep 17 00:00:00 2001 From: Jogisara Ramachandra Sandesh Bhat Date: Sun, 6 Oct 2024 14:30:52 +0200 Subject: [PATCH 5/5] Add workflow to deploy hugo website to github pages Copied from samples as found here: https://gohugo.io/hosting-and-deployment/hosting-on-github/ Change into web directory before building Change directory for uploading artifacts --- .github/workflows/hugo.yaml | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/hugo.yaml diff --git a/.github/workflows/hugo.yaml b/.github/workflows/hugo.yaml new file mode 100644 index 0000000..3720061 --- /dev/null +++ b/.github/workflows/hugo.yaml @@ -0,0 +1,78 @@ +# Sample workflow for building and deploying a Hugo site to GitHub Pages +name: Deploy Hugo site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash + +jobs: + # Build job + build: + runs-on: ubuntu-latest + env: + HUGO_VERSION: 0.134.2 + steps: + - name: Install Hugo CLI + run: | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - name: Install Dart Sass + run: sudo snap install dart-sass + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Install Node.js dependencies + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + - name: Build with Hugo + env: + HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache + HUGO_ENVIRONMENT: production + TZ: America/Los_Angeles + run: | + cd web && hugo \ + --gc \ + --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./web/public + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file