mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-25 15:58:53 +00:00
Miscellaneous edits
This commit is contained in:
@@ -12,9 +12,9 @@ weight: 90
|
||||
---
|
||||
## Image resources
|
||||
|
||||
To process an image, you must access the image as either a page resource or a global resource.
|
||||
To process an image you must access the file as a page resource, global resource, or remote resource.
|
||||
|
||||
### Page resources
|
||||
### Page resource
|
||||
|
||||
A page resource is a file within a [page bundle]. A page bundle is a directory with an `index.md` or `_index.md` file at its root.
|
||||
|
||||
@@ -26,13 +26,15 @@ content/
|
||||
└── sunset.jpg <-- page resource
|
||||
```
|
||||
|
||||
### Global resources
|
||||
To access an image as a page resource:
|
||||
|
||||
A global resource is a file:
|
||||
```go-html-template
|
||||
{{ $image := .Resources.Get "sunset.jpg" }}
|
||||
```
|
||||
|
||||
- Within the `assets` directory, or
|
||||
- Within any directory [mounted] to the `assets` directory, or
|
||||
- Located on a remote server accessible via `http` or `https`
|
||||
### Global resource
|
||||
|
||||
A global resource is a file within the `assets` directory, or within any directory [mounted] to the `assets` directory.
|
||||
|
||||
```text
|
||||
assets/
|
||||
@@ -40,13 +42,15 @@ assets/
|
||||
└── sunset.jpg <-- global resource
|
||||
```
|
||||
|
||||
To access a local image as a global resource:
|
||||
To access an image as a global resource:
|
||||
|
||||
```go-html-template
|
||||
{{ $image := resources.Get "images/sunset.jpg" }}
|
||||
```
|
||||
|
||||
To access a remote image as a global resource:
|
||||
### Remote resource
|
||||
|
||||
A remote resource is a file on a remote server, accessible via http or https. To access an image as a remote resource:
|
||||
|
||||
```go-html-template
|
||||
{{ $image := resources.GetRemote "https://gohugo.io/img/hugo-logo.png" }}
|
||||
@@ -80,6 +84,21 @@ Example 3: A more concise way to skip image rendering if the resource is not fou
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Example 4: Skips rendering if there's problem accessing a remote resource.
|
||||
|
||||
```go-html-template
|
||||
{{ $u := "https://gohugo.io/img/hugo-logo.png" }}
|
||||
{{ with resources.GetRemote $u }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "%s" . }}
|
||||
{{ else }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get remote resource %q" $u }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
## Image processing methods
|
||||
|
||||
The `image` resource implements the [`Resize`], [`Fit`], [`Fill`], [`Crop`], [`Filter`], [`Colors`] and [`Exif`] methods.
|
||||
|
||||
@@ -102,9 +102,10 @@ subtitle = 'Reference, Tutorials, and Explanations'
|
||||
In Hugo `v0.112.0` we consolidated all configuration options, and improved how the languages and their parameters are merged with the main configuration. But while testing this on Hugo sites out there, we received some error reports and reverted some of the changes in favor of deprecation warnings:
|
||||
|
||||
1. `site.Language.Params` is deprecated. Use `site.Params` directly.
|
||||
1. Adding custom parameters to the top level language configuration is deprecated, add all of these below `[params]`, see `color` in the example below.
|
||||
1. Adding custom parameters to the top level language configuration is deprecated. Define custom parameters within `languages.xx.params`. See `color` in the example below.
|
||||
|
||||
{{< code-toggle file=hugo copy=false >}}
|
||||
|
||||
```toml
|
||||
title = "My blog"
|
||||
languageCode = "en-us"
|
||||
|
||||
@@ -114,7 +115,7 @@ title = "Min blogg"
|
||||
languageCode = "sv"
|
||||
[languages.en.params]
|
||||
color = "blue"
|
||||
```
|
||||
{{< /code-toggle >}}
|
||||
|
||||
In the example above, all settings except `color` below `params` map to predefined configuration options in Hugo for the site and its language, and should be accessed via the documented accessors:
|
||||
|
||||
@@ -510,7 +511,7 @@ See [lang.FormatNumber] and [lang.FormatNumberCustom] for details.
|
||||
With this template code:
|
||||
|
||||
```go-html-template
|
||||
{{ 512.5032 | lang.FormatPercent 2 }} → 512.50%
|
||||
{{ 512.5032 | lang.FormatPercent 2 }}
|
||||
```
|
||||
|
||||
The rendered page displays:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: anchorize
|
||||
description: Takes a string and sanitizes it the same way as the [`defaultMarkdownHandler`](/getting-started/configuration-markup#configure-markup) does for markdown headers.
|
||||
description: Takes a string and sanitizes it the same way as the [`defaultMarkdownHandler`](/getting-started/configuration-markup#default-configuration) does for markdown headers.
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Configure markup
|
||||
description: How to handle Markdown and other markup related configuration.
|
||||
description: Configure rendering of markup to HTML.
|
||||
categories: [fundamentals, getting started]
|
||||
keywords: [configuration,highlighting]
|
||||
menu:
|
||||
@@ -12,9 +12,9 @@ slug: configuration-markup
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Configure markup
|
||||
## Default configuration
|
||||
|
||||
See [Goldmark](#goldmark) for settings related to the default Markdown handler in Hugo.
|
||||
See [Goldmark](#goldmark) for settings related to the default markdown handler in Hugo.
|
||||
|
||||
Below are all markup related configuration in Hugo with their default settings:
|
||||
|
||||
@@ -22,7 +22,7 @@ Below are all markup related configuration in Hugo with their default settings:
|
||||
|
||||
**See each section below for details.**
|
||||
|
||||
### Goldmark
|
||||
## Goldmark
|
||||
|
||||
[Goldmark](https://github.com/yuin/goldmark/) is from Hugo 0.60 the default library used for Markdown. It's fast, it's [CommonMark](https://spec.commonmark.org/0.29/) compliant and it's very flexible.
|
||||
|
||||
@@ -38,7 +38,7 @@ hardWraps
|
||||
: By default, Goldmark ignores newlines within a paragraph. Set to `true` to render newlines as `<br>` elements.
|
||||
|
||||
unsafe
|
||||
: By default, Goldmark does not render raw HTMLs and potentially dangerous links. If you have lots of inline HTML and/or JavaScript, you may need to turn this on.
|
||||
: By default, Goldmark does not render raw HTML and potentially dangerous links. If you have lots of inline HTML and/or JavaScript, you may need to turn this on.
|
||||
|
||||
typographer
|
||||
: This extension substitutes punctuations with typographic entities like [smartypants](https://daringfireball.net/projects/smartypants/).
|
||||
@@ -82,7 +82,7 @@ Note that attributes in [code fences](/content-management/syntax-highlighting/#h
|
||||
autoHeadingIDType ("github")
|
||||
: The strategy used for creating auto IDs (anchor names). Available types are `github`, `github-ascii` and `blackfriday`. `github` produces GitHub-compatible IDs, `github-ascii` will drop any non-Ascii characters after accent normalization, and `blackfriday` will make the IDs compatible with Blackfriday, the default Markdown engine before Hugo 0.60. Note that if Goldmark is your default Markdown engine, this is also the strategy used in the [anchorize](/functions/anchorize/) template func.
|
||||
|
||||
### Highlight
|
||||
## Highlight
|
||||
|
||||
This is the default `highlight` configuration. Note that some of these settings can be set per code block, see [Syntax Highlighting](/content-management/syntax-highlighting/).
|
||||
|
||||
@@ -95,7 +95,7 @@ For `style`, see these galleries:
|
||||
|
||||
For CSS, see [Generate Syntax Highlighter CSS](/content-management/syntax-highlighting/#generate-syntax-highlighter-css).
|
||||
|
||||
### Table of contents
|
||||
## Table of contents
|
||||
|
||||
{{< code-toggle config="markup.tableOfContents" />}}
|
||||
|
||||
@@ -108,7 +108,7 @@ endLevel
|
||||
: The heading level, inclusive, to stop render the table of contents.
|
||||
|
||||
ordered
|
||||
: Whether or not to generate an ordered list instead of an unordered list.
|
||||
: If `true`, generates an ordered list instead of an unordered list.
|
||||
|
||||
## Markdown render hooks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user