{"id":19175833,"url":"https://github.com/handcraftedbits/docker-nginx-unit-hugo","last_synced_at":"2025-10-25T17:23:36.938Z","repository":{"id":95812280,"uuid":"63910143","full_name":"handcraftedbits/docker-nginx-unit-hugo","owner":"handcraftedbits","description":"A Docker container that provides a Hugo unit for NGINX Host","archived":false,"fork":false,"pushed_at":"2017-11-16T18:34:44.000Z","size":22,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T01:33:06.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/handcraftedbits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-22T00:05:12.000Z","updated_at":"2024-02-20T19:21:20.000Z","dependencies_parsed_at":"2023-04-30T12:01:52.282Z","dependency_job_id":null,"html_url":"https://github.com/handcraftedbits/docker-nginx-unit-hugo","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/handcraftedbits%2Fdocker-nginx-unit-hugo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/handcraftedbits%2Fdocker-nginx-unit-hugo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/handcraftedbits%2Fdocker-nginx-unit-hugo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/handcraftedbits%2Fdocker-nginx-unit-hugo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/handcraftedbits","download_url":"https://codeload.github.com/handcraftedbits/docker-nginx-unit-hugo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252940934,"owners_count":21828769,"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":[],"created_at":"2024-11-09T10:25:33.624Z","updated_at":"2025-10-25T17:23:31.884Z","avatar_url":"https://github.com/handcraftedbits.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NGINX Host Hugo Unit [![Docker Pulls](https://img.shields.io/docker/pulls/handcraftedbits/nginx-unit-hugo.svg?maxAge=2592000)](https://hub.docker.com/r/handcraftedbits/nginx-unit-hugo)\n\nA [Docker](https://www.docker.com) container that provides a [Hugo](https://gohugo.io) unit for\n[NGINX Host](https://github.com/handcraftedbits/docker-nginx-host).  This unit **only** supports Hugo sites that\nare available via a remote source control repository.\n\n# Features\n\n* Hugo v0.30.2\n* Can automatically regenerate your Hugo site upon a push to your [GitHub](https://github.com) or\n  [GitLab](https://gitlab.com) repository\n\n# Usage\n\n## Prerequisites\n\n### `NGINX_UNIT_HOSTS` Considerations\n\nIt is important that the value of your `NGINX_UNIT_HOSTS` environment variable doesn't include wildcards or regular\nexpressions as this value will be used by Hugo to determine the base URL of your site.  Also, if the variable contains\nmultiple hosts (e.g., `myhost.com,otherhost.com`), only the first host (the one before the `,`) will be used.\n\n## Configuration\n\nIt is highly recommended that you use container orchestration software such as\n[Docker Compose](https://www.docker.com/products/docker-compose) when using this NGINX Host unit as several Docker\ncontainers are required for operation.  This guide will assume that you are using Docker Compose.\n\nTo begin, start with a basic `docker-compose.yml` file as described in the\n[NGINX Host configuration guide](https://github.com/handcraftedbits/docker-nginx-host#configuration).  Then, add a\nservice for the NGINX Host Hugo unit (named `hugo`):\n\n```yaml\nhugo:\n  image: handcraftedbits/nginx-unit-hugo\n  environment:\n    - NGINX_UNIT_HOSTS=mysite.com\n    - NGINX_URL_PREFIX=/blog\n    - HUGO_REPO_URL=https://github.com/mysite/blog.git\n    - HUGO_REPO_SECRET=password\n    - HUGO_THEME=my_hugo_theme\n  volumes:\n    - data:/opt/container/shared\n```\n\nObserve the following:\n\n* Several environment variables are used to configure Hugo.  See the\n  [environment variable reference](#reference) for additional information.\n* As with any other NGINX Host unit, we mount our data volume, in this case named `data`, to `/opt/container/shared`.\n\nFinally, we need to create a link in our NGINX Host container to the `hugo` container in order to host Hugo.  Here is\nour final `docker-compose.yml` file:\n\n```yaml\nversion: \"2.1\"\n\nvolumes:\n  data:\n\nservices:\n  hugo:\n    image: handcraftedbits/nginx-unit-hugo\n    environment:\n      - NGINX_UNIT_HOSTS=mysite.com\n      - NGINX_URL_PREFIX=/blog\n      - HUGO_REPO_URL=https://github.com/mysite/blog.git\n      - HUGO_REPO_SECRET=password\n      - HUGO_THEME=my_hugo_theme\n    volumes:\n      - data:/opt/container/shared\n\n  proxy:\n    image: handcraftedbits/nginx-host\n    links:\n      - hugo\n    ports:\n      - \"443:443\"\n    volumes:\n      - data:/opt/container/shared\n      - /etc/letsencrypt:/etc/letsencrypt\n      - /home/me/dhparam.pem:/etc/ssl/dhparam.pem\n```\n\nThis will result in making Hugo available at `https://mysite.com/blog`.\n\n### Theme Considerations\n\nThe NGINX Host Hugo unit assumes that all themes are stored alongside your content in your repository.  This means that\nthe value of the `HUGO_THEME` environment variable should specify the name of a directory in your repository that\ncontains the Hugo theme you wish to use.\n\nThe easiest way to store your themes alongside your content is to simply copy the theme into a directory.  A better\napproach, if the theme is available in its own Git repository, is to use a\n[Git submodule](https://git-scm.com/docs/git-submodule), for example:\n\n```bash\ngit submodule add user@myrepo.com:my_theme themes/my_theme\n```\n\n### Enabling Site Regeneration After Git Repository Push\n\nIf your content repository is stored in GitHub or GitLab, your Hugo site can be automatically regenerated after a push.\nSimply [create a GitHub webhook](https://developer.github.com/webhooks/creating/) or a\n[GitLab webhook](https://docs.gitlab.com/ce/user/project/integrations/webhooks.html) for your repository with the URL\n\n`https://\u003chost\u003e/\u003cprefix\u003e/rebuild`\n\nwhere `\u003chost\u003e` is your server's hostname and `\u003cprefix\u003e` is `webhooks-hugo` if the environment variable\n`NGINX_URL_PREFIX` is set to `/` or `webhooks-\u003csitePrefix\u003e` if `NGINX_URL_PREFIX` is set to `\u003csitePrefix\u003e`.\nFor example, if the blog is hosted at `https://mysite.com/`, then the webhook URL will be\n`https://mysite.com/webhooks-hugo/rebuild`; if the blog is hosted at `https://mysite.com/blog` (i.e.,\n`NGINX_URL_PREFIX` is set to `/blog`), the webhook URL will be `https://mysite.com/webhooks-blog/rebuild`.\n\nYou will also need to set the environment variable `HUGO_REPO_SECRET` to the secret value specified during\nconfiguration of the webhook in GitHub or GitLab.\n\n### Pre-build Script\n\nYou can run a pre-build script (for example, to copy resources before Hugo generates your site) by attaching a file to\nthe `/opt/container/script/pre-hugo-build.sh` volume, for example:\n\n```yaml\nhugo:\n  image: handcraftedbits/nginx-unit-hugo\n  environment:\n    - NGINX_UNIT_HOSTS=mysite.com\n    - NGINX_URL_PREFIX=/blog\n    - HUGO_REPO_URL=https://github.com/mysite/blog.git\n    - HUGO_REPO_SECRET=password\n    - HUGO_THEME=my_hugo_theme\n  volumes:\n    - data:/opt/container/shared\n    - /home/me/my-pre-build-script.sh:/opt/container/script/pre-hugo-build.sh\n```\n\nThe directory where your Hugo repository has been cloned will be provided to this script as the first argument.\n\n### Post-build Script\n\nYou can run a post-build script (for example, to minimize HTML after Hugo generates your site) by attaching a file to\nthe `/opt/container/script/post-hugo-build.sh` volume, for example:\n\n```yaml\nhugo:\n  image: handcraftedbits/nginx-unit-hugo\n  environment:\n    - NGINX_UNIT_HOSTS=mysite.com\n    - NGINX_URL_PREFIX=/blog\n    - HUGO_REPO_URL=https://github.com/mysite/blog.git\n    - HUGO_REPO_SECRET=password\n    - HUGO_THEME=my_hugo_theme\n  volumes:\n    - data:/opt/container/shared\n    - /home/me/my-post-build-script.sh:/opt/container/script/post-hugo-build.sh\n```\n\nThe directory where your Hugo repository has been cloned will be provided to this script as the first argument.\n\n## Running the NGINX Host Hugo Unit\n\nAssuming you are using Docker Compose, simply run `docker-compose up` in the same directory as your\n`docker-compose.yml` file.  Otherwise, you will need to start each container with `docker run` or a suitable\nalternative, making sure to add the appropriate environment variables and volume references.\n\n# Reference\n\n## Environment Variables\n\n### `HUGO_IGNORE_CACHE`\n\nUsed to ignore Hugo's cache directory (i.e., calls Hugo with the `--ignoreCache` parameter) if set to `true`.\n\n**Default value**: `false`\n\n### `HUGO_REPO_BRANCH`\n\nThe branch of the Git repository hosting your Hugo site.\n\n**Default value**: `master`\n\n### `HUGO_REPO_SECRET`\n\nThe secret value used when setting up the Hugo site rebuild webhook on GitHub or GitLab.\n\n**Required**\n\n### `HUGO_REPO_URL`\n\nThe URL of the Git repository hosting your Hugo site.\n\n**Required** if your Git repository is hosted on GitHub or GitLab.\n\n### `HUGO_THEME`\n\nThe name of the theme used to render your Hugo site.\n\n**Required**\n\n### Others\n\nPlease see the NGINX Host [documentation](https://github.com/handcraftedbits/docker-nginx-host#units) and\n[docker-nginx-unit-webhook documentation](https://github.com/handcraftedbits/docker-nginx-unit-webhook#environment-variables)\nfor information on additional environment variables understood by this unit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandcraftedbits%2Fdocker-nginx-unit-hugo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhandcraftedbits%2Fdocker-nginx-unit-hugo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandcraftedbits%2Fdocker-nginx-unit-hugo/lists"}