# Functions Various useful utilities for Hugo static generated site. ## Install ### Config [Import module](https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme) in your site configuration: ```yaml imports: - path: gitlab.com/toby3d/hugo/functions ``` ## Usage ### `srcset` Generates the `srcset` attribute for adaptive image resources. Takes an image resource as an argument and returns an attribute with references to alternate sizes of that resource. If no alternate resources can be generated based on the settings, an empty string will be returned. #### Config Add the following parameters to the site configuration. The example below shows the default values: ```yaml params: imaging: min: 50 # Minimum width for generated images max: 1000 # Maximum width for generated images count: 20 # Maximum number of generated images ``` #### Usage ```html {{- $image := resources.GetMatch "sample" -}} ``` #### Result ```html ``` ### `wbr` Renders long URLs with hyphenation tags. See «[Better Line Breaks for Long URLs](https://css-tricks.com/better-line-breaks-for-long-urls/)». #### Usage ```html {{ partial "functions/wbr" $.Page.Permalink | safeHTML }} ``` #### Result ```html http://www.example.com/s/ref=sr_nr_i_o ```