Hugo: Difference between revisions

Layer-09 (talk | contribs)
Cleaned up and clarified the page
Klinger (talk | contribs)
m Category Go added
 
(2 intermediate revisions by one other user not shown)
Line 68: Line 68:
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
<!--T:12-->
Navigate to the site directory and add a theme as a git submodule or download it directly. For detailed steps, refer to the official Hugo documentation.
Navigate to the site directory and add a theme as a git submodule or download it directly. For detailed steps, refer to the official Hugo documentation.
</translate>
</translate>
Line 81: Line 82:


<translate>
<translate>
<!--T:10-->
=== Development Shell === <!--T:devshell-->
{{Expansion|reason=Section incomplete, needs more tips and tricks}}
 
<!--T:13-->
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>}}
 
<!--T:14-->
To avoid typing <code>nix-shell</code> or <code>nix develop</code> to access the dev shell, consider [[Direnv|enabling nix-direnv]].
</translate>
 
<translate>
=== Theming === <!--T:theming-->
 
<!--T:15-->
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>}}
 
<!--T:16-->
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>


Line 96: Line 147:
[[Category:Applications]]
[[Category:Applications]]
[[Category:Server]]
[[Category:Server]]
[[Category:Go]]