This was created after changing to the blank theme.
Hugo notes
From https://gohugobrasil.netlify.app/themes/creating/ (old?) and https://gohugo.io/hugo-modules/theme-components/
- A theme consists of templates and static assets such as javascript and css files.
- Themes can also provide archetypes, which are archetypal content types used by the hugo new command to scaffold new content files with preconfigured front matter.
- Website content is displayed in two different ways, a single piece of content and a list of content items.
- The default single file layout is located at layouts/_default/single.html.
- The default list file layout is located at layouts/_default/list.html.
- Partials are a special template type that enables the themes end user to be able to overwrite just a small piece of a file or inject code into the theme from their local /layouts.
- https://gohugobrasil.netlify.app/templates/partials/
- Partials are smaller, context-aware components in your list and page templates that can be used economically to keep your templating DRY.
- Everything in the static directory will be copied directly into the final site when rendered.
- Theme customization in Hugo is a matter of overriding the templates made available to you in a theme.
- This is supposed to provide “flexibility of tweaking a theme to meet your needs while staying current with a theme’s upstream”, ha ha.
- Types of template:
- Homepage
- Base
- Section Page
- Taxonomy List
- Taxonomy Terms
- Single Page
- RSS
- Shortcode
- Each type of template has its own spec for the template lookup order.
- Themes can be stacked like inheritance.
- For i18n and data files, Hugo merges deeply using the translation ID and data key inside the files.
- For static, layouts (templates), and archetypes files, the first file found takes precedence.
- When two files have the same path, the file in the project directory takes precedence.
https://gohugo.io/content-management/page-resources/ https://gohugo.io/content-management/image-processing/
- Page resources are only accessible from page bundles, those directories with index.md or _index.md files at their root.
- A page resource is a file within a page bundle.
- Page resources are only available to the page with which they are bundled.
- A global resource is a file within the assets directory, or within any directory mounted to the assets directory.
- A remote resource is a file on a remote server, accessible via HTTP or HTTPS.
- Once you have accessed an image as either a page resource or a global resource, render it in your templates using the Permalink, RelPermalink, Width, and Height properties.
- The image resource implements the Process, Resize, Fit, Fill, Crop, Filter, Colors and Exif methods.
- Hugo caches processed images in the resources directory. If you include this directory in source control, Hugo will not have to regenerate the images.
- If you change image processing methods or options, or if you rename or remove images, the resources directory will contain unused images. To remove the unused images, perform garbage collection with
hugo --gc.
https://gohugo.io/content-management/organization/
- _index.md has a special role in Hugo. It allows you to add front matter and content to your list templates.
- section templates
- taxonomy templates
- taxonomy terms templates
- homepage template
- all _index.md files in a Hugo project are used to add content and front matter to list pages
https://gohugo.io/getting-started/directory-structure/
- archetypes: templates for new content
- assets: global resources typically passed through an asset pipeline such as images, CSS, Sass, JavaScript, and TypeScript
- config: site configuration
- content: markup files and page resources
- data: data files that augment content, configuration, localization, and navigation
- i18n: translation tables for multilingual sites
- layouts: templates to transform content, data, and resources
- public : he published website
- resources : ached output from Hugo’s asset pipelines
- static: files that will be copied to the public directory
- themes: themes
https://gohugo.io/templates/introduction/
- Each Go Template gets a data object. In Hugo, each template is passed a Page.
- With the Page being the default scope of a template, the Title element in current scope (. - “the dot”) is accessible simply by the dot-prefix (.Title)
https://gohugo.io/templates/base/
- The base and block constructs allow you to define the outer shell of your master templates (i.e., the chrome of the page).
- What?
- The block keyword allows you to fill in or override portions as necessary.
<body>{{ block "main" . }} ... {{ end }} {{ block "footer" . }} ... {{ end }}</body>- What is the dot after the name for?
- This replaces the contents of our “main” block:
{{ define "main" }} ... {{ end }}
- Code that you put outside the block definitions can break your layout.
- So, like, don’t?
Tags: