https://github.com/thenewdynamic/hugo-module-tnd-tags
A Hugo Module to generate HTML tags
https://github.com/thenewdynamic/hugo-module-tnd-tags
Last synced: 4 months ago
JSON representation
A Hugo Module to generate HTML tags
- Host: GitHub
- URL: https://github.com/thenewdynamic/hugo-module-tnd-tags
- Owner: theNewDynamic
- License: mit
- Created: 2020-06-26T17:53:17.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2021-08-20T15:18:39.000Z (almost 5 years ago)
- Last Synced: 2025-10-22T17:51:15.504Z (8 months ago)
- Language: HTML
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Tags Hugo Module
Hugo Module to genererate HTML tags.
Remove HTML/templating concern when having to generate large amount of tags (SEO etc...)
## Requirements
Requirements:
- Go 1.14
- Hugo 0.61.0
## Installation
If not already, [init](https://gohugo.io/hugo-modules/use-modules/#initialize-a-new-module) your project as Hugo Module:
```
$: hugo mod init {repo_url}
```
Configure your project's module to import this module:
```yaml
# config.yaml
module:
imports:
- path: github.com/theNewDynamic/hugo-module-tnd-tags
```
## Usage
### tag
The tag partial takes 3 parameters
- name*: the tag's name: `link` or `script` etc...
- inner: The tag's content. If not set, the tag will self close.
- attr: A map with the tag's attributes.
#### Examples
##### title
```
{{ partial "tnd-tags/tag" (dict "name" "title" "inner" "Hugo Tags!") }}
```
```html
Hugo Tags!
````
##### link
```
{{ range resources.Match "fonts/**/*.woff*" }}
{{ $params := dict "name" "link" "attr" (dict "href" .RelPermalink "rel" "prefetch" "as" "font" "crossorigin" "") }}
{{ partial "tnd-tags/tag" $params }}
```
```html
```
##### script
```
{{ with resources.Get "main.js" }}
{{ $param := dict
"name" "script"
"attr" (dict
"type" "text/javascript"
"src" .RelPermalink
"defer" ""
)
) }}
{{ partial "tnd-tags/tag $param }}
{{ end }}
```
```html
```
----
```
{{ partial "tnd-tags/tag" (dict
"name" "script"
"inner" `console.log('bonjour vous!')`
) }}
```
```html
var text = 'Hello Tag!';
console.log(text);
```
## theNewDynamic
This project is maintained and love by [thenewDynamic](https://www.thenewdynamic.com).