{"id":13474760,"url":"https://github.com/peaceiris/actions-hugo","last_synced_at":"2025-05-13T20:22:49.851Z","repository":{"id":37830946,"uuid":"187902720","full_name":"peaceiris/actions-hugo","owner":"peaceiris","description":"GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended, Hugo Modules, Linux (Ubuntu), macOS, and Windows are supported.","archived":false,"fork":false,"pushed_at":"2024-11-15T02:27:11.000Z","size":2326,"stargazers_count":1490,"open_issues_count":29,"forks_count":90,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-05T19:16:06.346Z","etag":null,"topics":["actions","github-actions","hugo"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/hugo-setup","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peaceiris.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"peaceiris","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-05-21T19:42:54.000Z","updated_at":"2025-05-04T01:41:06.000Z","dependencies_parsed_at":"2024-01-06T13:08:40.392Z","dependency_job_id":"f70d7d80-0a76-44d4-b195-4b4c155198d8","html_url":"https://github.com/peaceiris/actions-hugo","commit_stats":{"total_commits":761,"total_committers":15,"mean_commits":"50.733333333333334","dds":0.4704336399474376,"last_synced_commit":"3b443076f02aa9537a31bdcaa0c971cdd41eb022"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peaceiris%2Factions-hugo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peaceiris%2Factions-hugo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peaceiris%2Factions-hugo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peaceiris%2Factions-hugo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peaceiris","download_url":"https://codeload.github.com/peaceiris/actions-hugo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166502,"owners_count":21864475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","github-actions","hugo"],"created_at":"2024-07-31T16:01:14.628Z","updated_at":"2025-05-13T20:22:44.842Z","avatar_url":"https://github.com/peaceiris.png","language":"TypeScript","funding_links":["https://github.com/sponsors/peaceiris"],"categories":["Community Resources","TypeScript","hugo","Starters","五、按场景分类的实用Action"],"sub_categories":["Frontend Tools","Non-Official","5. 部署发布"],"readme":"## GitHub Actions for Hugo\n\n\u003cimg width=\"400\" alt=\"GitHub Actions for Hugo\" src=\"./images/ogp.svg\"\u003e\n\n[![Project status: active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![license](https://img.shields.io/github/license/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/blob/main/LICENSE)\n[![release](https://img.shields.io/github/release/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases/latest)\n[![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases)\n[![Release Feed](https://img.shields.io/badge/release-feed-yellow)](https://github.com/peaceiris/actions-hugo/releases.atom)\n![Test](https://github.com/peaceiris/actions-hugo/workflows/Test/badge.svg?branch=main\u0026event=push)\n![Code Scanning](https://github.com/peaceiris/actions-hugo/workflows/Code%20Scanning/badge.svg?event=push)\n\n[![CodeFactor](https://www.codefactor.io/repository/github/peaceiris/actions-hugo/badge)](https://www.codefactor.io/repository/github/peaceiris/actions-hugo)\n[![codecov](https://codecov.io/gh/peaceiris/actions-hugo/branch/main/graph/badge.svg)](https://codecov.io/gh/peaceiris/actions-hugo)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ebf2eef3a046b396ba9c/maintainability)](https://codeclimate.com/github/peaceiris/actions-hugo/maintainability)\n\nThis **Hugo Setup Action** can install [Hugo] to a virtual machine of **GitHub Actions**.\n**Hugo extended** version, **Hugo Modules**, Linux (Ubuntu), macOS, and Windows are supported.\n\n[Hugo]: https://github.com/gohugoio/hugo\n\nFrom `v2`, this Hugo Setup Action has migrated to a JavaScript (TypeScript) action.\nWe no longer build or pull a Hugo docker image.\nThanks to this change, we can complete this action in less than a few seconds.\n(A docker base action was taking about 1 min or more execution time to build and pull a docker image.)\n\n| OS (runs-on) | ubuntu-latest, ubuntu-20.04, ubuntu-22.04 | macos-latest | windows-2019 |\n|---|:---:|:---:|:---:|\n| Support | ✅️ | ✅️ | ✅️ |\n\n| Hugo type | Hugo Extended | Hugo Modules | Latest Hugo |\n|---|:---:|:---:|:---:|\n| Support | ✅️ | ✅️ | ✅️ |\n\n\n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Getting started](#getting-started)\n  - [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow)\n- [Options](#options)\n  - [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended)\n  - [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo)\n- [Tips](#tips)\n  - [⭐️ Caching Hugo Modules](#%EF%B8%8F-caching-hugo-modules)\n  - [⭐️ Read Hugo version from file](#%EF%B8%8F-read-hugo-version-from-file)\n  - [⭐️ Workflow for autoprefixer and postcss-cli](#%EF%B8%8F-workflow-for-autoprefixer-and-postcss-cli)\n  - [⭐️ Workflow for asciidoctor](#%EF%B8%8F-workflow-for-asciidoctor)\n  - [⭐️ Non-ascii Filename](#%EF%B8%8F-non-ascii-filename)\n- [CHANGELOG](#changelog)\n- [License](#license)\n- [About Maintainer](#about-maintainer)\n- [Maintainer Notes](#maintainer-notes)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n\n## Getting started\n\n### ⭐️ Create your workflow\n\nAn example workflow `.github/workflows/gh-pages.yml` with [GitHub Actions for GitHub Pages].\nFor the first deployment, we have to do this operation: [First Deployment with `GITHUB_TOKEN` - peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-first-deployment-with-github_token)\n\n[GitHub Actions for GitHub Pages]: https://github.com/peaceiris/actions-gh-pages\n\n[![peaceiris/actions-gh-pages - GitHub](https://gh-card.dev/repos/peaceiris/actions-gh-pages.svg?fullname)](https://github.com/peaceiris/actions-gh-pages)\n\n```yaml\nname: GitHub Pages\n\non:\n  push:\n    branches:\n      - main  # Set a branch to deploy\n  pull_request:\n\njobs:\n  deploy:\n    runs-on: ubuntu-22.04\n    concurrency:\n      group: ${{ github.workflow }}-${{ github.ref }}\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          submodules: true  # Fetch Hugo themes (true OR recursive)\n          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod\n\n      - name: Setup Hugo\n        uses: peaceiris/actions-hugo@v3\n        with:\n          hugo-version: '0.119.0'\n          # extended: true\n\n      - name: Build\n        run: hugo --minify\n\n      - name: Deploy\n        uses: peaceiris/actions-gh-pages@v3\n        if: github.ref == 'refs/heads/main'\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          publish_dir: ./public\n```\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n\n\n## Options\n\n### ⭐️ Use Hugo extended\n\nSet `extended: true` to use a Hugo extended version.\n\n```yaml\n- name: Setup Hugo\n  uses: peaceiris/actions-hugo@v3\n  with:\n    hugo-version: '0.119.0'\n    extended: true\n```\n\n### ⭐️ Use the latest version of Hugo\n\nSet `hugo-version: 'latest'` to use the latest version of Hugo.\n\n```yaml\n- name: Setup Hugo\n  uses: peaceiris/actions-hugo@v3\n  with:\n    hugo-version: 'latest'\n```\n\nThis action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo)\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n\n\n## Tips\n\n### ⭐️ Caching Hugo Modules\n\nInsert a cache step before site-building as follows.\n\nFirst, to maximize compatibility with all Hugo versions, let's define the variable `HUGO_CACHEDIR`:\n\n```yaml\n# * ...\n\njobs:\n  deploy:\n    runs-on: ubuntu-22.04\n    env:\n      HUGO_CACHEDIR: /tmp/hugo_cache # \u003c- Define the env variable here, so that Hugo's cache dir is now predictible in your workflow and doesn't depend on the Hugo's version you're using.\n\n# * ...\n```\n\nNow, let's add the cache action call just above the _Build_ step:\n\n```yaml\n- uses: actions/cache@v4\n  with:\n    path: ${{ env.HUGO_CACHEDIR }} # \u003c- Use the same env variable just right here\n    key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}\n    restore-keys: |\n      ${{ runner.os }}-hugomod-\n\n- name: Build\n  run: hugo --minify\n```\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n### ⭐️ Read Hugo version from file\n\nHow to sync a Hugo version between a Docker Compose and a GitHub Actions workflow via `.env` file.\n\nWrite a `HUGO_VERSION` to the `.env` file like the following and push it to a remote branch.\n\n```sh\nHUGO_VERSION=0.119.0\n```\n\nNext, add a step to read a Hugo version from the `.env` file.\n\n```yaml\n    - name: Read .env\n      id: hugo-version\n      run: |\n        . ./.env\n        echo \"HUGO_VERSION=${HUGO_VERSION}\" \u003e\u003e \"${GITHUB_OUTPUT}\"\n\n    - name: Setup Hugo\n      uses: peaceiris/actions-hugo@v3\n      with:\n        hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'\n        extended: true\n```\n\nHere is a `docker-compose.yml` example.\n\n```yaml\nversion: '3'\n\nservices:\n  hugo:\n    container_name: hugo\n    image: \"peaceiris/hugo:v${HUGO_VERSION}\"\n    # image: peaceiris/hugo:v${HUGO_VERSION}-mod   # Hugo Modules\n    # image: peaceiris/hugo:v${HUGO_VERSION}-full  # Hugo Modules and Node.js\n    ports:\n      - 1313:1313\n    volumes:\n      - ${PWD}:/src\n    command:\n      - server\n      - --bind=0.0.0.0\n      - --buildDrafts\n```\n\nThe alpine base Hugo Docker image is provided on the following repository.\n\n\u003e [peaceiris/hugo-extended-docker: Hugo alpine base Docker image (Hugo extended and Hugo Modules)](https://github.com/peaceiris/hugo-extended-docker)\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n### ⭐️ Workflow for autoprefixer and postcss-cli\n\nHere is an example workflow for the [google/docsy] Hugo theme.\nThis theme needs `autoprefixer` and `postcss-cli` to build a project.\nThe following workflow is tested with [google/docsy-example].\n\n[google/docsy]: https://github.com/google/docsy\n[google/docsy-example]: https://github.com/google/docsy-example\n\nA workflow for the Hugo Babel pipeline is also the same as follows.\n\n```yaml\nname: GitHub Pages\n\non:\n  push:\n    branches:\n      - master  # Set a branch to deploy\n  pull_request:\n\njobs:\n  deploy:\n    runs-on: ubuntu-22.04\n    concurrency:\n      group: ${{ github.workflow }}-${{ github.ref }}\n    steps:\n      - uses: actions/checkout@4\n        with:\n          fetch-depth: 0         # Fetch all history for .GitInfo and .Lastmod\n\n      - name: Setup Hugo\n        uses: peaceiris/actions-hugo@v3\n        with:\n          hugo-version: '0.119.0'\n          extended: true\n\n      - uses: actions/setup-node@v4\n        with:\n          node-version: '20'\n          cache: 'npm'\n          # The action defaults to search for the dependency file (package-lock.json,\n          # npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its\n          # hash as a part of the cache key.\n          # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data\n          cache-dependency-path: '**/package-lock.json'\n\n      - run: npm ci\n      - run: hugo --minify\n\n      - name: Deploy\n        uses: peaceiris/actions-gh-pages@v3\n        if: github.ref == 'refs/heads/master'\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n### ⭐️ Workflow for asciidoctor\n\nHere is an example workflow for a Hugo project using `asciidoctor`.\n\n```yaml\nname: GitHub Pages\n\non:\n  push:\n    branches:\n      - main  # Set a branch to deploy\n  pull_request:\n\njobs:\n  deploy:\n    runs-on: ubuntu-22.04\n    concurrency:\n      group: ${{ github.workflow }}-${{ github.ref }}\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          submodules: true  # Fetch Hugo themes (true OR recursive)\n          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod\n\n      - name: Setup Hugo\n        uses: peaceiris/actions-hugo@v3\n        with:\n          hugo-version: '0.119.0'\n          extended: true\n\n      - name: Setup Ruby\n        uses: ruby/setup-ruby@v1\n        with:\n          ruby-version: 3.2\n\n      - run: gem install asciidoctor\n\n      - name: Run Hugo\n        run: |\n          alias asciidoctor=\"asciidoctor --attribute=experimental=true --attribute=icons=font\"\n          hugo --minify\n\n      - name: Deploy\n        uses: peaceiris/actions-gh-pages@v3\n        if: github.ref == 'refs/heads/main'\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n### ⭐️ Non-ascii Filename\n\ncf. [Gitinfo fails on unicode filename · Issue #3071 · gohugoio/hugo](https://github.com/gohugoio/hugo/issues/3071)\n\n```yaml\nname: GitHub Pages\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  deploy:\n    runs-on: ubuntu-22.04\n    concurrency:\n      group: ${{ github.workflow }}-${{ github.ref }}\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Disable quotePath\n        run: git config core.quotePath false\n\n      - name: Setup Hugo\n        uses: peaceiris/actions-hugo@v3\n        with:\n          hugo-version: '0.119.0'\n```\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n\n\n\n## CHANGELOG\n\n- [CHANGELOG.md](CHANGELOG.md)\n\n\n\n## License\n\n- [MIT License - peaceiris/actions-hugo]\n\n[MIT License - peaceiris/actions-hugo]: https://github.com/peaceiris/actions-hugo/blob/main/LICENSE\n\n\n\n## About Maintainer\n\n- [peaceiris homepage](https://peaceiris.com/)\n- [GitHub Action Hero: Shohei Ueda - The GitHub Blog](https://github.blog/2020-03-22-github-action-hero-shohei-ueda/)\n\n\n\n## Maintainer Notes\n\nRun `npm test` on a Docker container.\n\n```sh\n# On container\nmake build\nmake all\n\n# Release script on host\n./release.sh\n```\n\n\n\n\u003cdiv align=\"right\"\u003e\n\u003ca href=\"#table-of-contents\"\u003eBack to TOC ☝️\u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeaceiris%2Factions-hugo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeaceiris%2Factions-hugo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeaceiris%2Factions-hugo/lists"}