{"id":16581655,"url":"https://github.com/rootwork/hugo-module-site","last_synced_at":"2025-10-29T06:30:45.039Z","repository":{"id":43473275,"uuid":"462067061","full_name":"rootwork/hugo-module-site","owner":"rootwork","description":"An example of using Hugo modules for your Hugo site.","archived":false,"fork":false,"pushed_at":"2024-04-07T11:52:05.000Z","size":61,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-18T08:53:35.653Z","etag":null,"topics":["go-modules","hugo","hugo-module","hugo-modules","hugo-site"],"latest_commit_sha":null,"homepage":"","language":"Sass","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/rootwork.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":"2022-02-21T23:35:49.000Z","updated_at":"2025-05-18T16:09:36.000Z","dependencies_parsed_at":"2022-07-25T01:47:55.138Z","dependency_job_id":null,"html_url":"https://github.com/rootwork/hugo-module-site","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rootwork/hugo-module-site","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootwork%2Fhugo-module-site","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootwork%2Fhugo-module-site/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootwork%2Fhugo-module-site/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootwork%2Fhugo-module-site/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rootwork","download_url":"https://codeload.github.com/rootwork/hugo-module-site/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootwork%2Fhugo-module-site/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281576292,"owners_count":26524883,"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","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go-modules","hugo","hugo-module","hugo-modules","hugo-site"],"created_at":"2024-10-11T22:29:37.069Z","updated_at":"2025-10-29T06:30:44.799Z","avatar_url":"https://github.com/rootwork.png","language":"Sass","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hugo module testing site\n\nThis repo serves as an example of how to load both themes and content as Hugo\nmodules, which is the New Modern Way™ to avoid having to do clumsy git submodule\nworkflows with themes, and also allows you to keep your content in a dedicated\nrepo.\n\nI use it as a way to quickly test themes.\n\n## Requirements\n\n- [Go must be installed](https://go.dev/dl/) on your local machine.\n- Make sure you have a reasonably-recent version of Hugo (`hugo version`).\n  Modules were introduced in 0.55, but additional module-related commands and\n  settings have continued to appear up through at least 0.84.2.\n- Run `hugo mod help` and make sure you get back something that isn't an error,\n  which confirms that the first two requirements have been met.\n\n## Usage\n\n`hugo serve`\n\nWhen testing/changing module imports, it can sometimes be useful to use\n`hugo server --disableFastRender --gc` to ensure nothing is being cached.\n\n## Development\n\nSee [`config.toml`](config.toml) for a line-by-line commented guide, or read on.\n\n### Changing the theme\n\nBecause we're importing the theme using Hugo modules, **you do not need a\n`theme` key in your config file**. To change your theme, update the first\n`module.imports` `path` in the config file to a different theme's repository\naddress. This can be any git repo hosting a Hugo theme.\n\n#### Local theme development\n\nIf you're developing locally on the theme you're importing as a module (which\nwas my original use case) you can use the\n[`replacements` mapping feature](https://gohugo.io/hugo-modules/configuration/#module-config-top-level),\neither in the config file itself or as an environment variable.\n\nHowever, I had better success using the\n[`replace` directive](https://gohugo.io/hugo-modules/use-modules/#make-and-test-changes-in-a-module)\ndirectly in [`go.mod`](go.mod) instead of replacement mapping in the config file\n-- it avoids some issues when modules are nested. Also take a look at\n[this walk-through](https://www.staticsiteguru.com/post/module-replace/).\n\nIn either case, you'll need to run `hugo mod get` after you set these values and\nregenerate the site (don't rely on liveReload). In my testing I generally needed\nto run [`hugo mod vendor`](#verifying-whats-being-loaded-and-where) each time I\nchanged anything in the locally-loaded module. So the command I ended up using\na lot was:\n\n```sh\nhugo mod get \u0026\u0026 hugo mod vendor \u0026\u0026 hugo server --disableFastRender --gc\n```\n\n### Changing the content\n\nThe second `module.imports` `path`, and the `module.imports.mounts`\nsection below it, specifies the source of your content. If you want to use Hugo\nnormally (without importing content from another repo) simply remove this\nsection.\n\n#### Can I still use `hugo new` to create a post?\n\n**Sort of.** If you run the command `hugo new foo.md`, for instance, Hugo will\ncreate a _local_ file at `content/foo.md`. When rendering the site, that\nlocal file will then be published to `\u003cbaseURL\u003e/foo`. However, while you'll be\nable to navigate to that address, the theme may not be aware of the content. In\nother words, you'll be able to link to it, but it won't show up automatically in\nlists of posts.\n\nIn general, it's probably better to decide to either use a separate repo for all\nyour content, or generate all your content locally.\n\n### Loading other resources into Hugo from modules\n\nYou can use modules to\n[set mount points](https://gohugo.io/hugo-modules/configuration/#module-config-mounts)\nfor all of Hugo's base directories: `content`, `static`, `layouts`, `data`,\n`assets`, `i18n`, and `archetypes`.\n\nAs the comments in [`config.toml`](config.toml) illustrate, you can even have\nmultiple sources for some of these, such as separate content repos loaded by\nlanguage in a multilingual site.\n\n### Updating a module\n\nModules will be downloaded when you first add them; they won't be automatically\nupdated. If you want to update them you have\n[several options](https://gohugo.io/hugo-modules/use-modules/#update-modules):\n\n- Update all modules: `hugo mod get -u`\n- Update all modules recursively: `hugo mod get -u ./...`\n- Update a single module: `hugo mod get -u \u003crepo_path\u003e`\n- Update a single module to a specific branch:\n  `hugo mod get \u003crepo_path\u003e@\u003cbranch\u003e`\n- Update a single module to a specific version (tag [must use semver](https://go.dev/doc/modules/version-numbers)): `hugo mod get \u003crepo_path\u003e@\u003cgit_tag\u003e`\n\n### Verifying what's being loaded and where\n\nRun `hugo mod vendor` to load all modules (and their recursive dependencies) to\na local `_vendor` folder. As\n[Nick at Hugo for Developers](https://www.hugofordevelopers.com/articles/master-hugo-modules-managing-themes-as-modules/)\npoints out, this is very useful for debugging how modules are being mounted,\nespecially for \"not module ready\" Hugo themes.\n\n## Building your own Hugo module site\n\nIf you don't want to fork this project, you can create a site with Hugo modules\nfrom scratch. The first resource [listed below](#additional-resources) is a\ngreat walk-through, but the list of commands alone is:\n\n```sh\nhugo new site \u003csite_name\u003e\ncd \u003csite_name\u003e\nhugo mod init \u003crepo_url\u003e\n```\n\nThen add the `module` and `module.imports` sections of your Hugo config file,\nspecifying the module(s) you want to use.\n\nIf your Hugo site is in a subdirectory of your repo, be sure to run\n`hugo mod init` in the Hugo directory. The `go.mod` and `go.sum` files that get\ncreated need to be at the same level in your directory tree as the location\nwhere you run other `hugo` commands.\n\n## Additional resources\n\n- [Master Hugo Modules: Managing Themes as Modules](https://www.hugofordevelopers.com/articles/master-hugo-modules-managing-themes-as-modules/)\n- [How to use Hugo Modules](https://geeksocket.in/posts/hugo-modules/)\n- [How to add a theme using modules (for beginners)](https://discourse.gohugo.io/t/how-to-add-a-theme-using-modules-for-beginners/20665)\n- [Hugo modules for “dummies”](https://discourse.gohugo.io/t/hugo-modules-for-dummies/20758)\n- [Hugo Module replacements](https://www.staticsiteguru.com/post/module-replace/)\n- [My modular site (by bep)](https://github.com/bep/my-modular-site)\n- [Hugo Modules documentation](https://gohugo.io/hugo-modules/)\n\n## License\n\n[MIT](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootwork%2Fhugo-module-site","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frootwork%2Fhugo-module-site","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootwork%2Fhugo-module-site/lists"}