Become a backer or sponsor to support our work.
This module ships with several partials for Gravatar.
Module | github.com/hugomods/gravatar |
---|---|
Stats |
Requires extended Hugo and Go.
Import the github.com/hugomods/gravatar
module.
hugo.yaml
1import:
2 modules:
3 - path: github.com/hugomods/gravatar
hugo.toml
1[import]
2 [[import.modules]]
3 path = 'github.com/hugomods/gravatar'
hugo.json
1{
2 "import": {
3 "modules": [
4 {
5 "path": "github.com/hugomods/gravatar"
6 }
7 ]
8 }
9}
The following parameters can be overridden by partials’ parameters.
Name | Type | Default | Description |
---|---|---|---|
default | String | mp | The default image. Available options: 404 , mp , identicon , monsterid , wavatar , retro , robohash , blank or an image URL. |
forceDefault | Boolean | false | Force the default image to always load. |
size | Integer | 80 | Single pixel dimension, since the images are square. |
rating | String | - | Available options: g , pg , r and x . |
className | String | gravatar-img | The class name of img tag. |
hugo.yaml
1params:
2 gravatar:
3 default: mp
hugo.toml
1[params]
2 [params.gravatar]
3 default = 'mp'
hugo.json
1{
2 "params": {
3 "gravatar": {
4 "default": "mp"
5 }
6 }
7}
See configuration and Gravatar image request for details.
Partial | Description | Example |
---|---|---|
gravatar/avatar | renders a Gravatar image by a raw email address. | {{ partial "gravatar/avatar" "[email protected]" }} |
gravatar/avatar-hash | renders a Gravatar image by a MD5 encrypted email address hash. | {{ partial "gravatar/avatar-hash" "e7501ec2b3cd95d6af8964743c1d27c7" }} |
gravatar/avatar-params | allow specifying the default image, image size, rating and class name. | {{ partial "gravatar/avatar-params" $params }} , see partials’ parameters. |
gravatar/avatar-url | returns the Gravatar image URL instead of img tag. | {{ partial "gravatar/avatar-url" $params }} , see partials’ parameters. |
You can find more examples on https://hugomods.github.io/gravatar/.
The following parameters will override the global parameters if present.
Name | Type | Description |
---|---|---|
Id | String | The MD5 encrypted email address hash, you MUST provide one of the Id or Email . |
Email | String | The raw email address. |
Alt | String | The alternative text. |
Default | String | The default image. |
ForceDefault | Boolean | Force the default image to always load. |
Size | Integer | The image size. |
Rating | String | The image rating. |
ClassName | String | The class name of img tag. Doesn’t work with the gravatar/avatar-url partial. |
1{{ $params := dict (
2 "Id" "e7501ec2b3cd95d6af8964743c1d27c7"
3 "Size" 120
4 "Alt" "Foo"
5 "Default" "monsterid"
6 "ForceDefault" true
7 "Rating" "x"
8 "ClassName" "avatar-img-circle"
9) }}
10{{ partial "gravatar/avatar-params" $params }}
11{{ partial "gravatar/avatar-url" $params }}