{"id":18244290,"url":"https://github.com/stackb/rules_hugo","last_synced_at":"2025-04-04T13:31:15.375Z","repository":{"id":28031896,"uuid":"115869295","full_name":"stackb/rules_hugo","owner":"stackb","description":"Bazel build rules for hugo static website generator","archived":false,"fork":false,"pushed_at":"2024-02-20T04:03:26.000Z","size":88,"stargazers_count":45,"open_issues_count":8,"forks_count":37,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-20T13:41:33.111Z","etag":null,"topics":["bazel","hugo-theme"],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackb.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}},"created_at":"2017-12-31T15:02:24.000Z","updated_at":"2024-09-29T14:39:00.000Z","dependencies_parsed_at":"2023-01-14T07:59:12.970Z","dependency_job_id":null,"html_url":"https://github.com/stackb/rules_hugo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackb%2Frules_hugo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackb%2Frules_hugo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackb%2Frules_hugo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackb%2Frules_hugo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackb","download_url":"https://codeload.github.com/stackb/rules_hugo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247184988,"owners_count":20897872,"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":["bazel","hugo-theme"],"created_at":"2024-11-05T09:16:01.730Z","updated_at":"2025-04-04T13:31:15.073Z","avatar_url":"https://github.com/stackb.png","language":"Starlark","readme":"# `rules_hugo`\n\n[![Build Status](https://api.cirrus-ci.com/github/stackb/rules_hugo.svg)](https://cirrus-ci.com/github/stackb/rules_hugo)\n\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/bazelbuild/bazel-blog/master/images/bazel-icon.svg\" height=\"120\"/\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/gohugoio/hugoDocs/master/static/img/hugo-logo.png\" height=\"120\"/\u003e\u003c/td\u003e\n\u003c/tr\u003e\u003ctr\u003e\n\u003ctd\u003eRules\u003c/td\u003e\n\u003ctd\u003eHugo\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\n[Bazel](https://bazel.build) rules for building static websites with [Hugo](https://gohugo.io).\n\n## Repository Rules\n\n|               Name   |  Description |\n| -------------------: | :----------- |\n| [hugo_repository](#hugo_repository) | Load hugo dependency for this repo. |\n| [github_hugo_theme](#github_hugo_theme) | Load a hugo theme from github. |\n\n## Build Rules\n\n|               Name   |  Description |\n| -------------------: | :----------- |\n| [hugo_site](#hugo_site) | Declare a hugo site. |\n| [hugo_theme](#hugo_theme) | Declare a hugo theme. |\n\n## Usage\n\n### Add rules_hugo to your WORKSPACE and add a theme from github\n\n```python\n# Update these to latest\nRULES_HUGO_COMMIT = \"...\"\nRULES_HUGO_SHA256 = \"...\"\n\nhttp_archive(\n    name = \"build_stack_rules_hugo\",\n    url = \"https://github.com/stackb/rules_hugo/archive/%s.zip\" % RULES_HUGO_COMMIT,\n    sha256 = RULES_HUGO_SHA256,\n    strip_prefix = \"rules_hugo-%s\" % RULES_HUGO_COMMIT\n)\n\nload(\"@build_stack_rules_hugo//hugo:rules.bzl\", \"hugo_repository\", \"github_hugo_theme\")\n\n#\n# Load hugo binary itself\n#\n# Optionally, load a specific version of Hugo, with the 'version' argument\nhugo_repository(\n    name = \"hugo\",\n)\n\n#\n# This makes a filegroup target \"@com_github_yihui_hugo_xmin//:files\"\n# available to your build files\n#\ngithub_hugo_theme(\n    name = \"com_github_yihui_hugo_xmin\",\n    owner = \"yihui\",\n    repo = \"hugo-xmin\",\n    commit = \"c14ca049d0dd60386264ea68c91d8495809cc4c6\",\n)\n\n#\n# This creates a filegroup target from a released archive from GitHub\n# this is useful when a theme uses compiled / aggregated sources NOT found\n# in a source root.\n#\nhttp_archive(\n    name = \"com_github_thegeeklab_hugo_geekdoc\",\n    url = \"https://github.com/thegeeklab/hugo-geekdoc/releases/download/v0.34.2/hugo-geekdoc.tar.gz\",\n    sha256 = \"7fdd57f7d4450325a778629021c0fff5531dc8475de6c4ec70ab07e9484d400e\",\n    build_file_content=\"\"\"\nfilegroup(\n    name = \"files\",\n    srcs = glob([\"**\"]),\n    visibility = [\"//visibility:public\"]\n)\n    \"\"\"\n)\n```\n\n### Declare a hugo_site with a GitHub repository theme in your BUILD file\n\n```python\nload(\"@build_stack_rules_hugo//hugo:rules.bzl\", \"hugo_site\", \"hugo_theme\", \"hugo_serve\")\n\n# Declare a theme 'xmin'.  In this case the `name` and\n# `theme_name` are identical, so the `theme_name` could be omitted in this case.\nhugo_theme(\n    name = \"xmin\",\n    theme_name = \"xmin\",\n    srcs = [\n        \"@com_github_yihui_hugo_xmin//:files\",\n    ],\n)\n\n# Declare a site. Config file is required.\nmy_site_name = \"basic\"\n\nhugo_site(\n    name = my_site_name,\n    config = \"config.toml\",\n    content = [\n        \"_index.md\",\n        \"about.md\",\n    ],\n    quiet = False,\n    theme = \":xmin\",\n)\n\n# Run local development server\nhugo_serve(\n    name = \"local_%s\" % my_site_name,\n    dep = [\":%s\" % my_site_name],\n)\n\n# Tar it up\npkg_tar(\n    name = \"%s_tar\" % my_site_name,\n    srcs = [\":%s\" % my_site_name],\n)\n```\n\n### Declare a hugo_site with a GitHub released archive theme in your BUILD file\n```python\nload(\"@build_stack_rules_hugo//hugo:rules.bzl\", \"hugo_site\", \"hugo_theme\", \"hugo_serve\")\n\nhugo_theme(\n    name = \"hugo_theme_geekdoc\",\n    theme_name = \"hugo-geekdoc\",\n    srcs = [\n        \"@com_github_thegeeklab_hugo_geekdoc//:files\",\n    ],\n)\n\n# Note, here we are using the config_dir attribute to support multi-lingual configurations.\nhugo_site(\n    name = \"site_complex\",\n    config_dir = glob([\"config/**\"]),\n    content = glob([\"content/**\"]),\n    data = glob([\"data/**\"]),\n    quiet = False,\n    theme = \":hugo_theme_geekdoc\",\n)\n\n# Run local development server\nhugo_serve(\n    name = \"serve\",\n    dep = [\":site_complex\"],\n)\n```\n\n### Previewing the site\n\nExecute the following command:\n\n```shell\nbazel run //site_complex:serve\n```\n\nThen open your browser: [here](http://localhost:1313)\n\n\n### Build the site\n\nThe `hugo_site` target emits the output in the `bazel-bin` directory.\n\n```sh\n$ bazel build :basic\n[...]\nTarget //:basic up-to-date:\n  bazel-bin/basic\n[...]\n```\n```sh\n$ tree bazel-bin/basic\nbazel-bin/basic\n├── 404.html\n├── about\n│   └── index.html\n[...]\n```\n\nThe `pkg_tar` target emits a `%{name}_tar.tar` file containing all the Hugo output files.\n\n```sh\n$ bazel build :basic_tar\n[...]\nTarget //:basic up-to-date:\n  bazel-bin/basic_tar.tar\n```\n\n## End\n\nSee source code for details about additional rule attributes / parameters.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackb%2Frules_hugo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackb%2Frules_hugo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackb%2Frules_hugo/lists"}