An open API service indexing awesome lists of open source software.

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

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).