Tabla de Contenidos
Hugo
Generador de sitios webs estáticos.
Uso
Crear un nuevo sitio
hugo new site nombre-sitio
Congratulations! Your new Hugo site is created in /home/tempwin/www/hugo/foo. Just a few more steps and you're ready to go: 1. Download a theme into the same-named folder. Choose a theme from https://themes.gohugo.io/ or create your own with the "hugo new theme <THEMENAME>" command. 2. Perhaps you want to add some content. You can add single files with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>". 3. Start the built-in live server via "hugo server". Visit https://gohugo.io/ for quickstart guide and full documentation.
Esto creará una carpeta llamada nombre-sitio en la ruta en la que nos encontremos:
archetypesconfig.tomlcontentdatalayoutsstaticthemes
Instalar tema
Nos movemos dentro de la carpeta del nuevo sitio e inicializamos un repositorio Git vacío:
git init
Descargamos, en este caso, el tema Ananke a la carpeta themes:
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
Indicamos en la configuración (config.toml) que queremos usar ese tema:
theme = "ananke"
Añadir contenido
Manual
Creamos el contenido dentro de la carpeta content siguiendo la nomenclatura:
<CATEGORIA>/<FICHERO>.<FORMATO> y añadiendo metadatos.
Automático
Lo más cómodo es usar el comando new para facilitar ciertos datos:
hugo new posts/hola-mundo.md
Esto hará que se cree el fichero content/posts/hola-mundo.md con el contenido:
--- title: "Hola Mundo" date: 2021-04-03T16:12:51+02:00 draft: true ---
titleindica el título que tendrá la página. Corresponde también a un h1 dentro de la etiqueta headerdate: fechadraft: indica si el contenido es un borrador o no. Si está entrue, cuando vayamos a generar el contenido estático, Hugo se saltará su generación.
Arrancando el servidor
hugo server -D
Esto iniciará un servidor web accesible desde http://localhost:1313/
Podemos ir haciendo cambios y el servidor los detectará y actualizará la web. Procesará tanto la configuración como el contenido en Markdown.
Generar páginas estáticas
hugo
Si queremos que también incluya el contenido marcado como borrador (draft), le pasamos la opción -D.
La generación del contenido estático creará un directorio llamado public, este será el directorio que tendremos que subir a nuestro servidor web.
El comando hugo no elimina lo que ya estuviese generado, así que se debería borrar el directorio public antes de ejecutar ese comando
