Hugo: Difference between revisions
Cleaned up and clarified the page |
m Added back old content to "Tips and tricks" |
||
Line 81: | Line 81: | ||
<translate> | <translate> | ||
<!--T: | <!--T:devshell--> | ||
{{ | === Development Shell === | ||
You may want to limit Hugo installation to your project only. This allows contributors to use the exact dependencies specified for the project: | |||
{{file|shell.nix|nix|<nowiki> | |||
{ pkgs ? import <nixpkgs> {} }: | |||
pkgs.mkShellNoCC { | |||
packages = [ | |||
pkgs.hugo | |||
# Other dependencies for your project. | |||
]; | |||
} | |||
</nowiki>}} | |||
To avoid typing <code>nix-shell</code> or <code>nix develop</code> to access the dev shell, consider [[Direnv|enabling nix-direnv]]. | |||
</translate> | |||
<translate> | |||
<!--T:theming--> | |||
=== Theming === | |||
Nix can be used to deterministically import Hugo themes by pinning them to a specific revision: | |||
{{file|shell.nix|nix|<nowiki> | |||
{ pkgs ? import <nixpkgs> {} }: let | |||
hugo-theme = pkgs.fetchFromGitHub { | |||
owner = "vaga"; | |||
repo = "hugo-theme-m10c"; | |||
rev = "862c6e941be9bc46ce8adc6a2fa9e984ba647d6f"; | |||
hash = "sha256-wcJSGjL/u43hPLblPmUhusqiMmadVBWJhihRinRXqzg="; | |||
}; | |||
in | |||
pkgs.mkShellNoCC { | |||
packages = [ | |||
pkgs.hugo | |||
# Other dependencies for your project. | |||
]; | |||
shellHook = '' | |||
mkdir -p themes | |||
ln -snf "${hugo-theme}" themes/m10c | |||
''; | |||
} | |||
</nowiki>}} | |||
After creating a <code>hugo.toml</code> file like the following, activate the theme with <code>hugo new site . --force</code>: | |||
{{file|hugo.toml|toml|<nowiki> | |||
baseURL = 'https://example.com/' | |||
languageCode = 'en-us' | |||
title = 'example-site' | |||
theme = 'm10c' | |||
</nowiki>}} | |||
</translate> | </translate> | ||