From a3a40ff999a8778227810da5aa4eed2e0e6e588a Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 30 Sep 2023 21:03:52 -0700 Subject: [PATCH] Add return type to functions --- archetypes/functions.md | 11 +- archetypes/news/index.md | 5 +- archetypes/showcase/index.md | 5 +- content/en/about/what-is-hugo.md | 6 +- content/en/content-management/archetypes.md | 2 +- content/en/content-management/formats.md | 1 - .../image-processing/index.md | 8 +- content/en/content-management/multilingual.md | 24 +-- content/en/content-management/shortcodes.md | 4 +- .../content-management/syntax-highlighting.md | 2 +- content/en/content-management/taxonomies.md | 3 +- .../en/functions/{adddate.md => AddDate.md} | 10 +- content/en/functions/Format.md | 90 ++++++++++ content/en/functions/{get.md => Get.md} | 14 +- content/en/functions/GetPage.md | 11 +- content/en/functions/HasMenuCurrent.md | 35 ++++ content/en/functions/IsMenuCurrent.md | 33 ++++ content/en/functions/{param.md => Param.md} | 11 +- content/en/functions/{render.md => Render.md} | 11 +- content/en/functions/RenderString.md | 14 +- .../en/functions/{scratch.md => Scratch.md} | 12 +- content/en/functions/{store.md => Store.md} | 10 +- content/en/functions/Unix.md | 36 ++++ .../_common/go-template-functions.md | 3 + .../en/functions/{common => _common}/index.md | 0 content/en/functions/_common/locales.md | 3 + .../regular-expressions.md | 0 .../functions/_common/time-layout-string.md | 42 +++++ .../functions/{float.md => cast/ToFloat.md} | 16 +- .../en/functions/{int.md => cast/ToInt.md} | 16 +- .../functions/{string.md => cast/ToString.md} | 16 +- .../{after.md => collections/After.md} | 26 +-- .../{append.md => collections/Append.md} | 20 ++- .../{apply.md => collections/Apply.md} | 33 ++-- .../Complement.md} | 17 +- .../{delimit.md => collections/Delimit.md} | 16 +- .../{dict.md => collections/Dictionary.md} | 16 +- .../EchoParam.md} | 16 +- .../{first.md => collections/First.md} | 26 +-- .../{group.md => collections/Group.md} | 18 +- content/en/functions/collections/In.md | 38 +++++ .../IndexFunction.md} | 21 +-- .../Intersect.md} | 17 +- .../{isset.md => collections/IsSet.md} | 18 +- .../{keyvals.md => collections/KeyVals.md} | 17 +- .../{last.md => collections/Last.md} | 16 +- .../{merge.md => collections/Merge.md} | 20 ++- .../en/functions/collections/NewScratch.md | 22 +++ .../{querify.md => collections/Querify.md} | 20 ++- .../Reverse.md} | 12 +- .../functions/{seq.md => collections/Seq.md} | 23 +-- .../{shuffle.md => collections/Shuffle.md} | 17 +- .../{slice.md => collections/Slice.md} | 29 ++-- .../{sort.md => collections/Sort.md} | 16 +- content/en/functions/collections/SymDiff.md | 28 +++ .../{union.md => collections/Union.md} | 17 +- .../{uniq.md => collections/Uniq.md} | 16 +- .../{where.md => collections/Where.md} | 20 ++- .../en/functions/{cond.md => compare/Cond.md} | 16 +- .../{default.md => compare/Default.md} | 16 +- content/en/functions/{eq.md => compare/Eq.md} | 16 +- content/en/functions/{ge.md => compare/Ge.md} | 16 +- content/en/functions/{gt.md => compare/Gt.md} | 16 +- content/en/functions/{le.md => compare/Le.md} | 16 +- content/en/functions/{lt.md => compare/Lt.md} | 16 +- content/en/functions/{ne.md => compare/Ne.md} | 15 +- content/en/functions/countrunes.md | 28 --- .../{crypto.FNV32a.md => crypto/FNV32a.md} | 12 +- .../en/functions/{hmac.md => crypto/HMAC.md} | 16 +- .../en/functions/{md5.md => crypto/MD5.md} | 16 +- .../en/functions/{sha1.md => crypto/SHA1.md} | 17 +- .../functions/{sha256.md => crypto/SHA256.md} | 17 +- content/en/functions/data/GetCSV.md | 117 +++++++++++++ content/en/functions/data/GetJSON.md | 124 ++++++++++++++ content/en/functions/dateformat.md | 55 ------ content/en/functions/debug/Dump.md | 50 ++++++ .../Base64Decode.md} | 18 +- .../Base64Encode.md} | 17 +- .../{jsonify.md => encoding/Jsonify.md} | 22 +-- .../en/functions/{errorf.md => fmt/Errorf.md} | 20 ++- .../{erroridf.md => fmt/Erroridf.md} | 18 +- .../en/functions/{print.md => fmt/Print.md} | 16 +- .../en/functions/{printf.md => fmt/Printf.md} | 16 +- .../functions/{println.md => fmt/Println.md} | 16 +- .../en/functions/{warnf.md => fmt/Warnf.md} | 18 +- content/en/functions/format.md | 121 ------------- content/en/functions/{ => go-template}/len.md | 13 +- content/en/functions/go-template/range.md | 159 ++++++++++++++++++ .../functions/{ => go-template}/urlquery.md | 14 +- .../en/functions/{ => go-template}/with.md | 16 +- content/en/functions/hasmenucurrent.md | 23 --- .../en/functions/{hugo.md => hugo/index.md} | 17 +- content/en/functions/images/index.md | 3 +- content/en/functions/in.md | 32 ---- .../{humanize.md => inflect/Humanize.md} | 16 +- .../{pluralize.md => inflect/Pluralize.md} | 16 +- .../Singularize.md} | 20 ++- content/en/functions/ismenucurrent.md | 21 --- content/en/functions/lang.md | 14 -- content/en/functions/lang/FormatAccounting.md | 27 +++ content/en/functions/lang/FormatCurrency.md | 27 +++ content/en/functions/lang/FormatNumber.md | 27 +++ .../en/functions/lang/FormatNumberCustom.md | 41 +++++ content/en/functions/lang/FormatPercent.md | 27 +++ .../{lang.Merge.md => lang/Merge.md} | 12 +- .../functions/{i18n.md => lang/Translate.md} | 57 ++++--- .../en/functions/{math.md => math/index.md} | 10 +- .../{fileExists.md => os/FileExists.md} | 17 +- .../en/functions/{getenv.md => os/Getenv.md} | 16 +- .../functions/{readdir.md => os/ReadDir.md} | 22 +-- .../functions/{readfile.md => os/ReadFile.md} | 16 +- .../en/functions/{os.Stat.md => os/Stat.md} | 12 +- .../en/functions/{page.md => page/index.md} | 12 +- .../{partial.md => partials/Include.md} | 16 +- .../IncludeCached.md} | 15 +- .../functions/{path.Base.md => path/Base.md} | 12 +- .../{path.BaseName.md => path/BaseName.md} | 12 +- .../{path.Clean.md => path/Clean.md} | 12 +- .../en/functions/{path.Dir.md => path/Dir.md} | 12 +- .../en/functions/{path.Ext.md => path/Ext.md} | 12 +- .../functions/{path.Join.md => path/Join.md} | 12 +- .../{path.Split.md => path/Split.md} | 26 ++- content/en/functions/range.md | 19 --- .../{reflect.IsMap.md => reflect/IsMap.md} | 15 +- .../IsSlice.md} | 15 +- .../en/functions/{safeCSS.md => safe/CSS.md} | 16 +- .../functions/{safeHTML.md => safe/HTML.md} | 16 +- .../{safeHTMLAttr.md => safe/HTMLAttr.md} | 16 +- .../en/functions/{safeJS.md => safe/JS.md} | 16 +- .../functions/{safeJSStr.md => safe/JSStr.md} | 16 +- .../en/functions/{safeURL.md => safe/URL.md} | 17 +- .../en/functions/{site.md => site/index.md} | 13 +- content/en/functions/slicestr.md | 20 --- content/en/functions/strings.Repeat.md | 18 -- content/en/functions/strings.RuneCount.md | 27 --- .../functions/{chomp.md => strings/Chomp.md} | 20 ++- .../Contains.md} | 15 +- .../ContainsAny.md} | 15 +- .../ContainsNonSpace.md} | 13 +- .../{strings.Count.md => strings/Count.md} | 24 +-- content/en/functions/strings/CountRunes.md | 29 ++++ .../{countwords.md => strings/CountWords.md} | 16 +- .../FindRESubmatch.md} | 18 +- .../{findRe.md => strings/FindRe.md} | 18 +- .../FirstUpper.md} | 12 +- .../HasPrefix.md} | 17 +- .../HasSuffix.md} | 17 +- content/en/functions/strings/Repeat.md | 20 +++ .../{replace.md => strings/Replace.md} | 18 +- .../{replacere.md => strings/ReplaceRE.md} | 18 +- content/en/functions/strings/RuneCount.md | 28 +++ content/en/functions/strings/SliceString.md | 24 +++ .../functions/{split.md => strings/Split.md} | 18 +- .../{substr.md => strings/Substr.md} | 16 +- .../functions/{title.md => strings/Title.md} | 16 +- .../{lower.md => strings/ToLower.md} | 16 +- .../{upper.md => strings/ToUpper.md} | 17 +- .../en/functions/{trim.md => strings/Trim.md} | 16 +- .../TrimLeft.md} | 12 +- .../TrimPrefix.md} | 12 +- .../TrimRight.md} | 12 +- .../TrimSuffix.md} | 12 +- content/en/functions/strings/Truncate.md | 26 +++ content/en/functions/symdiff.md | 28 --- .../Exists.md} | 13 +- .../en/functions/{time.md => time/AsTime.md} | 20 ++- .../{duration.md => time/Duration.md} | 16 +- content/en/functions/time/Format.md | 76 +++++++++ content/en/functions/{now.md => time/Now.md} | 16 +- .../ParseDuration.md} | 12 +- .../en/functions/transform/CanHighlight.md | 22 +++ .../{emojify.md => transform/Emojify.md} | 15 +- .../HTMLEscape.md} | 16 +- .../HTMLUnescape.md} | 18 +- .../{highlight.md => transform/Highlight.md} | 18 +- .../functions/transform/HighlightCodeBlock.md | 43 +++++ .../Markdownify.md} | 16 +- .../{plainify.md => transform/Plainify.md} | 16 +- .../Remarshal.md} | 12 +- .../Unmarshal.md} | 15 +- content/en/functions/truncate.md | 24 --- content/en/functions/unix.md | 34 ---- .../{abslangurl.md => urls/AbsLangURL.md} | 16 +- .../functions/{absurl.md => urls/AbsURL.md} | 18 +- .../{anchorize.md => urls/Anchorize.md} | 16 +- .../{urls.JoinPath.md => urls/JoinPath.md} | 14 +- .../{urls.Parse.md => urls/Parse.md} | 12 +- content/en/functions/{ref.md => urls/Ref.md} | 16 +- .../{relLangURL.md => urls/RelLangURL.md} | 16 +- .../functions/{relref.md => urls/RelRef.md} | 16 +- .../functions/{relurl.md => urls/RelURL.md} | 18 +- .../functions/{urlize.md => urls/URLize.md} | 16 +- .../getting-started/configuration-markup.md | 2 +- content/en/getting-started/configuration.md | 17 +- content/en/getting-started/glossary.md | 2 +- .../hosting-on-firebase.md | 10 +- content/en/hugo-pipes/babel.md | 2 +- content/en/hugo-pipes/bundling.md | 2 +- content/en/hugo-pipes/fingerprint.md | 2 +- content/en/hugo-pipes/js.md | 2 +- content/en/hugo-pipes/minification.md | 2 +- content/en/hugo-pipes/postcss.md | 2 +- content/en/hugo-pipes/postprocess.md | 2 +- content/en/hugo-pipes/resource-from-string.md | 2 +- .../en/hugo-pipes/resource-from-template.md | 2 +- .../en/hugo-pipes/transpile-sass-to-css.md | 2 +- .../{common => _common}/01-editions.md | 0 .../{common => _common}/02-prerequisites.md | 0 .../03-prebuilt-binaries.md | 0 .../{common => _common}/04-docker.md | 0 .../05-build-from-source.md | 0 .../{common => _common}/homebrew.md | 0 .../installation/{common => _common}/index.md | 0 content/en/installation/bsd.md | 8 +- content/en/installation/linux.md | 12 +- content/en/installation/macos.md | 12 +- content/en/installation/windows.md | 10 +- content/en/readfiles/README.md | 16 -- content/en/readfiles/dateformatting.md | 87 ---------- content/en/readfiles/index.md | 3 - content/en/readfiles/sectionvars.md | 23 --- content/en/readfiles/testing.txt | 3 - content/en/templates/data-templates.md | 11 +- content/en/templates/files.md | 13 +- content/en/templates/introduction.md | 21 +-- content/en/templates/lists/index.md | 25 ++- content/en/templates/pagination.md | 10 +- content/en/templates/partials.md | 2 +- content/en/templates/section-templates.md | 4 +- content/en/templates/shortcode-templates.md | 8 +- content/en/templates/single-page-templates.md | 2 +- content/en/templates/taxonomy-templates.md | 9 +- .../en/troubleshooting/build-performance.md | 2 +- content/en/troubleshooting/faq.md | 2 +- content/en/variables/_index.md | 2 +- content/en/variables/git.md | 5 +- content/en/variables/page.md | 26 ++- content/en/variables/site.md | 6 +- content/en/variables/taxonomy.md | 2 +- hugo.toml | 2 +- layouts/_default/page.html | 34 ++++ layouts/partials/docs/functions-aliases.html | 12 ++ .../partials/docs/functions-signatures.html | 12 ++ layouts/partials/related.html | 2 +- resources/.gitattributes | 2 - ...s_d11fe7b62c27961c87ecd0f2490357b9.content | 1 - ....css_d11fe7b62c27961c87ecd0f2490357b9.json | 1 - ...s_8848f55d07695b7ff7188138f23d69e3.content | 18 -- ...p.js_8848f55d07695b7ff7188138f23d69e3.json | 1 - ...0_83801_1024x512_fill_catmullrom_top_2.png | Bin 68339 -> 0 bytes ...eb2110_83801_640x0_resize_catmullrom_2.png | Bin 23262 -> 0 bytes ...83801_8298a1fa052279512823ecd663d6f9c8.png | Bin 25555 -> 0 bytes 252 files changed, 2691 insertions(+), 1762 deletions(-) rename content/en/functions/{adddate.md => AddDate.md} (91%) create mode 100644 content/en/functions/Format.md rename content/en/functions/{get.md => Get.md} (88%) create mode 100644 content/en/functions/HasMenuCurrent.md create mode 100644 content/en/functions/IsMenuCurrent.md rename content/en/functions/{param.md => Param.md} (94%) rename content/en/functions/{render.md => Render.md} (86%) rename content/en/functions/{scratch.md => Scratch.md} (96%) rename content/en/functions/{store.md => Store.md} (97%) create mode 100644 content/en/functions/Unix.md create mode 100644 content/en/functions/_common/go-template-functions.md rename content/en/functions/{common => _common}/index.md (100%) create mode 100644 content/en/functions/_common/locales.md rename content/en/functions/{common => _common}/regular-expressions.md (100%) create mode 100644 content/en/functions/_common/time-layout-string.md rename content/en/functions/{float.md => cast/ToFloat.md} (83%) rename content/en/functions/{int.md => cast/ToInt.md} (86%) rename content/en/functions/{string.md => cast/ToString.md} (84%) rename content/en/functions/{after.md => collections/After.md} (80%) rename content/en/functions/{append.md => collections/Append.md} (89%) rename content/en/functions/{apply.md => collections/Apply.md} (76%) rename content/en/functions/{complement.md => collections/Complement.md} (87%) rename content/en/functions/{delimit.md => collections/Delimit.md} (77%) rename content/en/functions/{dict.md => collections/Dictionary.md} (90%) rename content/en/functions/{echoparam.md => collections/EchoParam.md} (78%) rename content/en/functions/{first.md => collections/First.md} (69%) rename content/en/functions/{group.md => collections/Group.md} (80%) create mode 100644 content/en/functions/collections/In.md rename content/en/functions/{index-function.md => collections/IndexFunction.md} (92%) rename content/en/functions/{intersect.md => collections/Intersect.md} (77%) rename content/en/functions/{isset.md => collections/IsSet.md} (81%) rename content/en/functions/{keyvals.md => collections/KeyVals.md} (75%) rename content/en/functions/{last.md => collections/Last.md} (61%) rename content/en/functions/{merge.md => collections/Merge.md} (81%) create mode 100644 content/en/functions/collections/NewScratch.md rename content/en/functions/{querify.md => collections/Querify.md} (76%) rename content/en/functions/{collections.Reverse.md => collections/Reverse.md} (71%) rename content/en/functions/{seq.md => collections/Seq.md} (69%) rename content/en/functions/{shuffle.md => collections/Shuffle.md} (68%) rename content/en/functions/{slice.md => collections/Slice.md} (50%) rename content/en/functions/{sort.md => collections/Sort.md} (94%) create mode 100644 content/en/functions/collections/SymDiff.md rename content/en/functions/{union.md => collections/Union.md} (84%) rename content/en/functions/{uniq.md => collections/Uniq.md} (65%) rename content/en/functions/{where.md => collections/Where.md} (94%) rename content/en/functions/{cond.md => compare/Cond.md} (87%) rename content/en/functions/{default.md => compare/Default.md} (91%) rename content/en/functions/{eq.md => compare/Eq.md} (70%) rename content/en/functions/{ge.md => compare/Ge.md} (75%) rename content/en/functions/{gt.md => compare/Gt.md} (75%) rename content/en/functions/{le.md => compare/Le.md} (75%) rename content/en/functions/{lt.md => compare/Lt.md} (75%) rename content/en/functions/{ne.md => compare/Ne.md} (68%) delete mode 100644 content/en/functions/countrunes.md rename content/en/functions/{crypto.FNV32a.md => crypto/FNV32a.md} (81%) rename content/en/functions/{hmac.md => crypto/HMAC.md} (80%) rename content/en/functions/{md5.md => crypto/MD5.md} (76%) rename content/en/functions/{sha1.md => crypto/SHA1.md} (64%) rename content/en/functions/{sha256.md => crypto/SHA256.md} (67%) create mode 100644 content/en/functions/data/GetCSV.md create mode 100644 content/en/functions/data/GetJSON.md delete mode 100644 content/en/functions/dateformat.md create mode 100644 content/en/functions/debug/Dump.md rename content/en/functions/{base64Decode.md => encoding/Base64Decode.md} (81%) rename content/en/functions/{base64Encode.md => encoding/Base64Encode.md} (53%) rename content/en/functions/{jsonify.md => encoding/Jsonify.md} (82%) rename content/en/functions/{errorf.md => fmt/Errorf.md} (74%) rename content/en/functions/{erroridf.md => fmt/Erroridf.md} (83%) rename content/en/functions/{print.md => fmt/Print.md} (69%) rename content/en/functions/{printf.md => fmt/Printf.md} (82%) rename content/en/functions/{println.md => fmt/Println.md} (64%) rename content/en/functions/{warnf.md => fmt/Warnf.md} (74%) delete mode 100644 content/en/functions/format.md rename content/en/functions/{ => go-template}/len.md (80%) create mode 100644 content/en/functions/go-template/range.md rename content/en/functions/{ => go-template}/urlquery.md (71%) rename content/en/functions/{ => go-template}/with.md (82%) delete mode 100644 content/en/functions/hasmenucurrent.md rename content/en/functions/{hugo.md => hugo/index.md} (94%) delete mode 100644 content/en/functions/in.md rename content/en/functions/{humanize.md => inflect/Humanize.md} (75%) rename content/en/functions/{pluralize.md => inflect/Pluralize.md} (61%) rename content/en/functions/{singularize.md => inflect/Singularize.md} (56%) delete mode 100644 content/en/functions/ismenucurrent.md delete mode 100644 content/en/functions/lang.md create mode 100644 content/en/functions/lang/FormatAccounting.md create mode 100644 content/en/functions/lang/FormatCurrency.md create mode 100644 content/en/functions/lang/FormatNumber.md create mode 100644 content/en/functions/lang/FormatNumberCustom.md create mode 100644 content/en/functions/lang/FormatPercent.md rename content/en/functions/{lang.Merge.md => lang/Merge.md} (83%) rename content/en/functions/{i18n.md => lang/Translate.md} (71%) rename content/en/functions/{math.md => math/index.md} (97%) rename content/en/functions/{fileExists.md => os/FileExists.md} (79%) rename content/en/functions/{getenv.md => os/Getenv.md} (84%) rename content/en/functions/{readdir.md => os/ReadDir.md} (81%) rename content/en/functions/{readfile.md => os/ReadFile.md} (83%) rename content/en/functions/{os.Stat.md => os/Stat.md} (88%) rename content/en/functions/{page.md => page/index.md} (96%) rename content/en/functions/{partial.md => partials/Include.md} (88%) rename content/en/functions/{partialCached.md => partials/IncludeCached.md} (88%) rename content/en/functions/{path.Base.md => path/Base.md} (82%) rename content/en/functions/{path.BaseName.md => path/BaseName.md} (81%) rename content/en/functions/{path.Clean.md => path/Clean.md} (83%) rename content/en/functions/{path.Dir.md => path/Dir.md} (84%) rename content/en/functions/{path.Ext.md => path/Ext.md} (82%) rename content/en/functions/{path.Join.md => path/Join.md} (83%) rename content/en/functions/{path.Split.md => path/Split.md} (59%) delete mode 100644 content/en/functions/range.md rename content/en/functions/{reflect.IsMap.md => reflect/IsMap.md} (59%) rename content/en/functions/{reflect.IsSlice.md => reflect/IsSlice.md} (58%) rename content/en/functions/{safeCSS.md => safe/CSS.md} (85%) rename content/en/functions/{safeHTML.md => safe/HTML.md} (86%) rename content/en/functions/{safeHTMLAttr.md => safe/HTMLAttr.md} (85%) rename content/en/functions/{safeJS.md => safe/JS.md} (85%) rename content/en/functions/{safeJSStr.md => safe/JSStr.md} (85%) rename content/en/functions/{safeURL.md => safe/URL.md} (93%) rename content/en/functions/{site.md => site/index.md} (84%) delete mode 100644 content/en/functions/slicestr.md delete mode 100644 content/en/functions/strings.Repeat.md delete mode 100644 content/en/functions/strings.RuneCount.md rename content/en/functions/{chomp.md => strings/Chomp.md} (58%) rename content/en/functions/{strings.Contains.md => strings/Contains.md} (64%) rename content/en/functions/{strings.ContainsAny.md => strings/ContainsAny.md} (74%) rename content/en/functions/{strings.ContainsNonSpace.md => strings/ContainsNonSpace.md} (82%) rename content/en/functions/{strings.Count.md => strings/Count.md} (54%) create mode 100644 content/en/functions/strings/CountRunes.md rename content/en/functions/{countwords.md => strings/CountWords.md} (70%) rename content/en/functions/{findresubmatch.md => strings/FindRESubmatch.md} (86%) rename content/en/functions/{findRe.md => strings/FindRe.md} (78%) rename content/en/functions/{strings.FirstUpper.md => strings/FirstUpper.md} (68%) rename content/en/functions/{strings.HasPrefix.md => strings/HasPrefix.md} (54%) rename content/en/functions/{strings.HasSuffix.md => strings/HasSuffix.md} (54%) create mode 100644 content/en/functions/strings/Repeat.md rename content/en/functions/{replace.md => strings/Replace.md} (66%) rename content/en/functions/{replacere.md => strings/ReplaceRE.md} (81%) create mode 100644 content/en/functions/strings/RuneCount.md create mode 100644 content/en/functions/strings/SliceString.md rename content/en/functions/{split.md => strings/Split.md} (50%) rename content/en/functions/{substr.md => strings/Substr.md} (84%) rename content/en/functions/{title.md => strings/Title.md} (81%) rename content/en/functions/{lower.md => strings/ToLower.md} (70%) rename content/en/functions/{upper.md => strings/ToUpper.md} (69%) rename content/en/functions/{trim.md => strings/Trim.md} (86%) rename content/en/functions/{strings.TrimLeft.md => strings/TrimLeft.md} (79%) rename content/en/functions/{strings.TrimPrefix.md => strings/TrimPrefix.md} (80%) rename content/en/functions/{strings.TrimRight.md => strings/TrimRight.md} (79%) rename content/en/functions/{strings.TrimSuffix.md => strings/TrimSuffix.md} (80%) create mode 100644 content/en/functions/strings/Truncate.md delete mode 100644 content/en/functions/symdiff.md rename content/en/functions/{templates.Exists.md => templates/Exists.md} (73%) rename content/en/functions/{time.md => time/AsTime.md} (90%) rename content/en/functions/{duration.md => time/Duration.md} (85%) create mode 100644 content/en/functions/time/Format.md rename content/en/functions/{now.md => time/Now.md} (87%) rename content/en/functions/{time.ParseDuration.md => time/ParseDuration.md} (85%) create mode 100644 content/en/functions/transform/CanHighlight.md rename content/en/functions/{emojify.md => transform/Emojify.md} (81%) rename content/en/functions/{htmlEscape.md => transform/HTMLEscape.md} (68%) rename content/en/functions/{htmlUnescape.md => transform/HTMLUnescape.md} (69%) rename content/en/functions/{highlight.md => transform/Highlight.md} (92%) create mode 100644 content/en/functions/transform/HighlightCodeBlock.md rename content/en/functions/{markdownify.md => transform/Markdownify.md} (81%) rename content/en/functions/{plainify.md => transform/Plainify.md} (62%) rename content/en/functions/{transform.Remarshal.md => transform/Remarshal.md} (91%) rename content/en/functions/{transform.Unmarshal.md => transform/Unmarshal.md} (90%) delete mode 100644 content/en/functions/truncate.md delete mode 100644 content/en/functions/unix.md rename content/en/functions/{abslangurl.md => urls/AbsLangURL.md} (92%) rename content/en/functions/{absurl.md => urls/AbsURL.md} (89%) rename content/en/functions/{anchorize.md => urls/Anchorize.md} (85%) rename content/en/functions/{urls.JoinPath.md => urls/JoinPath.md} (80%) rename content/en/functions/{urls.Parse.md => urls/Parse.md} (87%) rename content/en/functions/{ref.md => urls/Ref.md} (90%) rename content/en/functions/{relLangURL.md => urls/RelLangURL.md} (91%) rename content/en/functions/{relref.md => urls/RelRef.md} (91%) rename content/en/functions/{relurl.md => urls/RelURL.md} (88%) rename content/en/functions/{urlize.md => urls/URLize.md} (89%) rename content/en/installation/{common => _common}/01-editions.md (100%) rename content/en/installation/{common => _common}/02-prerequisites.md (100%) rename content/en/installation/{common => _common}/03-prebuilt-binaries.md (100%) rename content/en/installation/{common => _common}/04-docker.md (100%) rename content/en/installation/{common => _common}/05-build-from-source.md (100%) rename content/en/installation/{common => _common}/homebrew.md (100%) rename content/en/installation/{common => _common}/index.md (100%) delete mode 100644 content/en/readfiles/README.md delete mode 100644 content/en/readfiles/dateformatting.md delete mode 100644 content/en/readfiles/index.md delete mode 100644 content/en/readfiles/sectionvars.md delete mode 100644 content/en/readfiles/testing.txt create mode 100644 layouts/_default/page.html create mode 100644 layouts/partials/docs/functions-aliases.html create mode 100644 layouts/partials/docs/functions-signatures.html delete mode 100644 resources/.gitattributes delete mode 100644 resources/_gen/assets/css/output/css/app.css_d11fe7b62c27961c87ecd0f2490357b9.content delete mode 100644 resources/_gen/assets/css/output/css/app.css_d11fe7b62c27961c87ecd0f2490357b9.json delete mode 100644 resources/_gen/assets/js/output/js/app.js_8848f55d07695b7ff7188138f23d69e3.content delete mode 100644 resources/_gen/assets/js/output/js/app.js_8848f55d07695b7ff7188138f23d69e3.json delete mode 100644 resources/_gen/images/showcase/alora-labs/featured_hu15e97d42270c9e985a93353bc5eb2110_83801_1024x512_fill_catmullrom_top_2.png delete mode 100644 resources/_gen/images/showcase/alora-labs/featured_hu15e97d42270c9e985a93353bc5eb2110_83801_640x0_resize_catmullrom_2.png delete mode 100644 resources/_gen/images/showcase/alora-labs/featured_hu15e97d42270c9e985a93353bc5eb2110_83801_8298a1fa052279512823ecd663d6f9c8.png diff --git a/archetypes/functions.md b/archetypes/functions.md index 891458daa..cb0e7c930 100644 --- a/archetypes/functions.md +++ b/archetypes/functions.md @@ -1,11 +1,14 @@ --- -title: {{ replace .Name "-" " " | title }} -description: "" -signature: [] +title: {{ replace .File.ContentBaseName "-" " " | title }} +description: categories: [functions] keywords: [] menu: docs: parent: functions -relatedfuncs: [] +function: + aliases: [] + returnType: + signatures: [] +relatedFunctions: [] --- diff --git a/archetypes/news/index.md b/archetypes/news/index.md index 42e207e6a..fcc5b5835 100644 --- a/archetypes/news/index.md +++ b/archetypes/news/index.md @@ -1,6 +1,5 @@ --- -title: "{{ replace .Name "-" " " | title }}" -description: "" +title: {{ replace .File.ContentBaseName "-" " " | title }} +description: date: {{ .Date }} --- - diff --git a/archetypes/showcase/index.md b/archetypes/showcase/index.md index a21bb9726..04d454575 100644 --- a/archetypes/showcase/index.md +++ b/archetypes/showcase/index.md @@ -1,9 +1,9 @@ --- -title: {{ replace .Name "-" " " | title }} +title: {{ replace .File.ContentBaseName "-" " " | title }} date: {{ now.Format "2006-01-02" }} -description: "A short description of this page." +description: A short description of this page. # The URL to the site on the internet. siteURL: https://gohugo.io/ @@ -34,4 +34,3 @@ bio.md featured.png : A reasonably sized screenshot of your website. It can be named anything, but the name must start with "featured". The sample image is `1500x750` (2:1 aspect ratio). - diff --git a/content/en/about/what-is-hugo.md b/content/en/about/what-is-hugo.md index 9e28346dd..be564233f 100644 --- a/content/en/about/what-is-hugo.md +++ b/content/en/about/what-is-hugo.md @@ -36,13 +36,13 @@ Hugo is for people building a blog, a company site, a portfolio site, documentat [@spf13]: https://twitter.com/spf13 [Amazon S3]: https://aws.amazon.com/s3/ [Azure]: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website -[CloudFront]: https://aws.amazon.com/cloudfront/ "Amazon CloudFront" +[CloudFront]: https://aws.amazon.com/cloudfront/ [DreamHost]: https://www.dreamhost.com/ -[Firebase]: https://firebase.google.com/docs/hosting/ "Firebase static hosting" +[Firebase]: https://firebase.google.com/docs/hosting/ [GitHub Pages]: https://pages.github.com/ [GitLab Pages]: https://about.gitlab.com/features/pages/ [Go language]: https://go.dev/ -[GoDaddy]: https://www.godaddy.com/ "GoDaddy.com Hosting" +[GoDaddy]: https://www.godaddy.com/ [Google Cloud Storage]: https://cloud.google.com/storage/ [Heroku]: https://www.heroku.com/ [Jekyll]: https://jekyllrb.com/ diff --git a/content/en/content-management/archetypes.md b/content/en/content-management/archetypes.md index d811bbac2..fe460f91f 100644 --- a/content/en/content-management/archetypes.md +++ b/content/en/content-management/archetypes.md @@ -68,7 +68,7 @@ If none of these exists, Hugo uses a built-in default archetype. ## Functions and context -You can use any [template function] within an archetype. As shown above, the default archetype uses the [`replace`](/functions/replace/) function to replace hyphens with spaces when populating the title in front matter. +You can use any [template function] within an archetype. As shown above, the default archetype uses the [`replace`](/functions/strings/replace) function to replace hyphens with spaces when populating the title in front matter. Archetypes receive the following objects and values in [context]: diff --git a/content/en/content-management/formats.md b/content/en/content-management/formats.md index f85c304cf..690fecd1d 100644 --- a/content/en/content-management/formats.md +++ b/content/en/content-management/formats.md @@ -115,7 +115,6 @@ Markdown syntax is simple enough to learn in a single sitting. The following are * [Markdown Tutorial (Interactive), Garen Torikian][mdtutorial] * [The Markdown Guide, Matt Cone][mdguide] -[`emojify` function]: /functions/emojify/ [ascii]: https://asciidoctor.org/ [config]: /getting-started/configuration/ [developer tools]: /tools/ diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md index 4af4c104d..9cce9070a 100644 --- a/content/en/content-management/image-processing/index.md +++ b/content/en/content-management/image-processing/index.md @@ -115,7 +115,7 @@ Metadata (EXIF, IPTC, XMP, etc.) is not preserved during image transformation. U The `Process` method is also available as a filter, which is more effective if need to apply multiple filters to an image. See [Process filter](/functions/images/#process). {{% /note %}} -Process processes the image with the given specification. The specification can contain an optional action, one of `resize`, `crop`, `fit` or `fill`. This means that you can use this method instead of [`Resize`], [`Fit`], [`Fill`], or [`Crop`]. +Process processes the image with the given specification. The specification can contain an optional action, one of `resize`, `crop`, `fit` or `fill`. This means that you can use this method instead of [`Resize`], [`Fit`], [`Fill`], or [`Crop`]. See [Options](#image-processing-options) for available options. @@ -501,11 +501,11 @@ If you change image processing methods or options, or if you rename or remove im hugo --gc ``` -[time.Format]: /functions/dateformat +[time.Format]: /functions/time/format [`anchor`]: /content-management/image-processing#anchor [mounted]: /hugo-modules/configuration#module-configuration-mounts [page bundle]: /content-management/page-bundles -[`lang.FormatNumber`]: /functions/lang +[`lang.FormatNumber`]: /functions/lang/formatnumber [filters]: /functions/images [github.com/disintegration/imaging]: [Smartcrop]: @@ -519,4 +519,4 @@ hugo --gc [`Fit`]: #fit [`Resize`]: #resize [site configuration]: #processing-options -[`with`]: /functions/with/ +[`with`]: /functions/go-template/with/ diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md index ec187d663..d4e32d39b 100644 --- a/content/en/content-management/multilingual.md +++ b/content/en/content-management/multilingual.md @@ -468,7 +468,7 @@ English|Wednesday, November 3, 2021 Français|mercredi 3 novembre 2021 Deutsch|Mittwoch, 3. November 2021 -See [time.Format] for details. +See [`time.Format`] for details. ### Currency @@ -636,7 +636,7 @@ i18n|MISSING_TRANSLATION|en|wordCount To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there is more than one language, URLs must meet the following criteria: * Come from the built-in `.Permalink` or `.RelPermalink` -* Be constructed with the [`relLangURL` template function][rellangurl] or the [`absLangURL` template function][abslangurl] **OR** be prefixed with `{{ .LanguagePrefix }}` +* Be constructed with the [`relLangURL`] or [`absLangURL`] template function, or be prefixed with `{{ .LanguagePrefix }}` If there is more than one language defined, the `LanguagePrefix` variable will equal `/en` (or whatever your `CurrentLanguage` is). If not enabled, it will be an empty string (and is therefore harmless for single-language Hugo websites). @@ -657,23 +657,23 @@ hugo new content content/en/post/test.md hugo new content content/de/post/test.md ``` -[abslangurl]: /functions/abslangurl +[`abslangurl`]: /functions/urls/abslangurl [config]: /getting-started/configuration/ [contenttemplate]: /templates/single-page-templates/ [go-i18n-source]: https://github.com/nicksnyder/go-i18n [go-i18n]: https://github.com/nicksnyder/go-i18n [homepage]: /templates/homepage/ [Hugo Multilingual Part 1: Content translation]: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/ -[i18func]: /functions/i18n/ -[lang.FormatAccounting]: /functions/lang -[lang.FormatCurrency]: /functions/lang -[lang.FormatNumber]: /functions/lang -[lang.FormatNumberCustom]: /functions/lang -[lang.FormatPercent]: /functions/lang -[lang.Merge]: /functions/lang.merge/ +[i18func]: /functions/lang/translate +[lang.FormatAccounting]: /functions/lang/formataccounting +[lang.FormatCurrency]: /functions/lang/formatcurrency +[lang.FormatNumber]: /functions/lang/formatnumber +[lang.FormatNumberCustom]: /functions/lang/formatnumbercustom +[lang.FormatPercent]: /functions/lang/formatpercent +[lang.Merge]: /functions/lang/merge/ [menus]: /content-management/menus/ [OS environment]: /getting-started/configuration/#configure-with-environment-variables -[rellangurl]: /functions/rellangurl +[`rellangurl`]: /functions/urls/rellangurl [RFC 5646]: https://tools.ietf.org/html/rfc5646 [single page templates]: /templates/single-page-templates/ -[time.Format]: /functions/dateformat +[`time.Format`]: /functions/time/format diff --git a/content/en/content-management/shortcodes.md b/content/en/content-management/shortcodes.md index 670c5acc8..b1e32d902 100644 --- a/content/en/content-management/shortcodes.md +++ b/content/en/content-management/shortcodes.md @@ -187,7 +187,7 @@ Rendered: To specify one or more [highlighting options], include a quotation-encapsulated, comma-separated list: -[highlighting options]: /functions/highlight/ +[highlighting options]: /functions/transform/highlight/ ```text {{}} @@ -391,7 +391,7 @@ To learn more about creating custom shortcodes, see the [shortcode template docu [`figure` shortcode]: #figure [contentmanagementsection]: /content-management/formats/ [examplegist]: https://gist.github.com/spf13/7896402 -[figureelement]: https://html5doctor.com/the-figure-figcaption-elements/ "An article from HTML5 doctor discussing the fig and figcaption elements." +[figureelement]: https://html5doctor.com/the-figure-figcaption-elements/ [Hugo and the GDPR]: /about/hugo-and-gdpr/ [Instagram]: https://www.instagram.com/ [pagevariables]: /variables/page/ diff --git a/content/en/content-management/syntax-highlighting.md b/content/en/content-management/syntax-highlighting.md index 44dece2df..39fef0f9b 100644 --- a/content/en/content-management/syntax-highlighting.md +++ b/content/en/content-management/syntax-highlighting.md @@ -92,7 +92,7 @@ Gives this: ## Highlight template function -See [Highlight](/functions/highlight/). +See [Highlight](/functions/transform/highlight/). ## Highlighting in code fences diff --git a/content/en/content-management/taxonomies.md b/content/en/content-management/taxonomies.md index 14a467390..418c65d02 100644 --- a/content/en/content-management/taxonomies.md +++ b/content/en/content-management/taxonomies.md @@ -191,12 +191,11 @@ title: "Bruce Willis" wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis" {{< /code-toggle >}} -[`urlize` template function]: /functions/urlize/ [content section]: /content-management/sections/ [content type]: /content-management/types/ [documentation on archetypes]: /content-management/archetypes/ [front matter]: /content-management/front-matter/ [taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-list-templates [taxonomy templates]: /templates/taxonomy-templates/ -[terms within the taxonomy]: /templates/taxonomy-templates/#taxonomy-terms-templates "See how to order terms associated with a taxonomy" +[terms within the taxonomy]: /templates/taxonomy-templates/#taxonomy-terms-templates [configuration]: /getting-started/configuration/ diff --git a/content/en/functions/adddate.md b/content/en/functions/AddDate.md similarity index 91% rename from content/en/functions/adddate.md rename to content/en/functions/AddDate.md index 95ecc69a7..7f5b39b16 100644 --- a/content/en/functions/adddate.md +++ b/content/en/functions/AddDate.md @@ -2,13 +2,15 @@ title: .AddDate description: Returns the time corresponding to adding the given number of years, months, and days to the given time.Time value. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: [.AddDate YEARS MONTHS DAYS] +function: + aliases: [] + returnType: time.Time + signatures: [.AddDate YEARS MONTHS DAYS] +relatedFunctions: [] --- ```go-html-template diff --git a/content/en/functions/Format.md b/content/en/functions/Format.md new file mode 100644 index 000000000..e679cb2c4 --- /dev/null +++ b/content/en/functions/Format.md @@ -0,0 +1,90 @@ +--- +title: .Format +description: Returns a formatted time.Time value. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [.Format LAYOUT] +relatedFunctions: [] +toc: true +--- + +```go-template +{{ $t := "2023-01-27T23:44:58-08:00" }} +{{ $t = time.AsTime $t }} +{{ $format := "2 Jan 2006" }} + +{{ $t.Format $format }} → 27 Jan 2023 +``` + +{{% note %}} +To return a formatted and localized `time.Time` value, use the [`time.Format`] function instead. + +[`time.Format`]: /functions/time/format +{{% /note %}} + +Use the `.Format` method with any `time.Time` value, including the four predefined front matter dates: + +```go-html-template +{{ $format := "2 Jan 2006" }} + +{{ .Date.Format $format }} +{{ .PublishDate.Format $format }} +{{ .ExpiryDate.Format $format }} +{{ .Lastmod.Format $format }} +``` + +## Layout string + +{{% readfile file="/functions/_common/time-layout-string.md" %}} + +## Examples + +Given this front matter: + +{{< code-toggle fm=true copy=false >}} +title = "About time" +date = 2023-01-27T23:44:58-08:00 +{{< /code-toggle >}} + +The examples below were rendered in the `America/Los_Angeles` time zone: + +Format string|Result +:--|:-- +`Monday, January 2, 2006`|`Friday, January 27, 2023` +`Mon Jan 2 2006`|`Fri Jan 27 2023` +`January 2006`|`January 2023` +`2006-01-02`|`2023-01-27` +`Monday`|`Friday` +`02 Jan 06 15:04 MST`|`27 Jan 23 23:44 PST` +`Mon, 02 Jan 2006 15:04:05 MST`|`Fri, 27 Jan 2023 23:44:58 PST` +`Mon, 02 Jan 2006 15:04:05 -0700`|`Fri, 27 Jan 2023 23:44:58 -0800` + +## UTC and local time + +Convert and format any `time.Time` value to either Coordinated Universal Time (UTC) or local time. + +```go-html-template +{{ $t := "2023-01-27T23:44:58-08:00" }} +{{ $t = time.AsTime $t }} +{{ $format := "2 Jan 2006 3:04:05 PM MST" }} + +{{ $t.UTC.Format $format }} → 28 Jan 2023 7:44:58 AM UTC +{{ $t.Local.Format $format }} → 27 Jan 2023 11:44:58 PM PST +``` + +## Ordinal representation + +Use the [`humanize`](/functions/inflect/humanize) function to render the day of the month as an ordinal number: + +```go-html-template +{{ $t := "2023-01-27T23:44:58-08:00" }} +{{ $t = time.AsTime $t }} + +{{ humanize $t.Day }} of {{ $t.Format "January 2006" }} → 27th of January 2023 +``` diff --git a/content/en/functions/get.md b/content/en/functions/Get.md similarity index 88% rename from content/en/functions/get.md rename to content/en/functions/Get.md index 20bd3ba5a..142e9811b 100644 --- a/content/en/functions/get.md +++ b/content/en/functions/Get.md @@ -2,15 +2,17 @@ title: .Get description: Accesses positional and ordered parameters in shortcode declaration. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .Get INDEX - - .Get KEY +function: + aliases: [] + returnType: any + signatures: + - .Get INDEX + - .Get KEY +relatedFunctions: [] --- `.Get` is specifically used when creating your own [shortcode template][sc], to access the [positional and named](/templates/shortcode-templates/#positional-vs-named-parameters) parameters passed to it. When used with a numeric INDEX, it queries positional parameters (starting with 0). With a string KEY, it queries named parameters. diff --git a/content/en/functions/GetPage.md b/content/en/functions/GetPage.md index 43e2717ee..4afebaca7 100644 --- a/content/en/functions/GetPage.md +++ b/content/en/functions/GetPage.md @@ -2,14 +2,15 @@ title: .GetPage description: Gets a `Page` of a given `path`. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .GetPage PATH +function: + aliases: [] + returnType: + signatures: [.GetPage PATH] +relatedFunctions: [] --- `.GetPage` returns a page of a given `path`. Both `Site` and `Page` implements this method. The `Page` variant will, if given a relative path -- i.e. a path without a leading `/` -- try look for the page relative to the current page. diff --git a/content/en/functions/HasMenuCurrent.md b/content/en/functions/HasMenuCurrent.md new file mode 100644 index 000000000..5b4200c56 --- /dev/null +++ b/content/en/functions/HasMenuCurrent.md @@ -0,0 +1,35 @@ +--- +title: .HasMenuCurrent +description: Reports whether the given page object matches the page object associated with one of the child menu entries under the given menu entry in the given menu. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: bool + signatures: [PAGE.HasMenuCurrent MENU MENUENTRY] +relatedFunctions: + - .HasMenuCurrent + - .IsMenuCurrent +--- + +If the page object associated with the menu entry is a section, this method also returns `true` for any descendant of that section. + +```go-html-template +{{ $currentPage := . }} +{{ range site.Menus.main }} + {{ if $currentPage.IsMenuCurrent .Menu . }} + {{ .Name }} + {{ else if $currentPage.HasMenuCurrent .Menu . }} + {{ .Name }} + {{ else }} + {{ .Name }} + {{ end }} +{{ end }} +``` + +See [menu templates] for a complete example. + +[menu templates]: /templates/menu-templates/#example diff --git a/content/en/functions/IsMenuCurrent.md b/content/en/functions/IsMenuCurrent.md new file mode 100644 index 000000000..c9980b3e8 --- /dev/null +++ b/content/en/functions/IsMenuCurrent.md @@ -0,0 +1,33 @@ +--- +title: .IsMenuCurrent +description: Reports whether the given page object matches the page object associated with the given menu entry in the given menu. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: bool + signatures: [PAGE.IsMenuCurrent MENU MENUENTRY] +relatedFunctions: + - .HasMenuCurrent + - .IsMenuCurrent +--- + +```go-html-template +{{ $currentPage := . }} +{{ range site.Menus.main }} + {{ if $currentPage.IsMenuCurrent .Menu . }} + {{ .Name }} + {{ else if $currentPage.HasMenuCurrent .Menu . }} + {{ .Name }} + {{ else }} + {{ .Name }} + {{ end }} +{{ end }} +``` + +See [menu templates] for a complete example. + +[menu templates]: /templates/menu-templates/#example diff --git a/content/en/functions/param.md b/content/en/functions/Param.md similarity index 94% rename from content/en/functions/param.md rename to content/en/functions/Param.md index 92831a63a..a2826a3c8 100644 --- a/content/en/functions/param.md +++ b/content/en/functions/Param.md @@ -2,14 +2,15 @@ title: .Param description: Returns a page parameter, falling back to a site parameter if present. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .Param KEY +function: + aliases: [] + returnType: any + signatures: [.Param KEY] +relatedFunctions: [] --- The `.Param` method on `.Page` looks for the given `KEY` in page parameters, and returns the corresponding value. If it cannot find the `KEY` in page parameters, it looks for the `KEY` in site parameters. If it cannot find the `KEY` in either location, the `.Param` method returns `nil`. diff --git a/content/en/functions/render.md b/content/en/functions/Render.md similarity index 86% rename from content/en/functions/render.md rename to content/en/functions/Render.md index 1d5228c71..02567845f 100644 --- a/content/en/functions/render.md +++ b/content/en/functions/Render.md @@ -2,14 +2,15 @@ title: .Render description: Takes a view to apply when rendering content. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .Render LAYOUT +function: + aliases: [] + returnType: template.HTML + signatures: [.Render LAYOUT] +relatedFunctions: [] --- The view is an alternative layout and should be a file name that points to a template in one of the locations specified in the documentation for [Content Views](/templates/views). diff --git a/content/en/functions/RenderString.md b/content/en/functions/RenderString.md index 60edc5673..91414d6a0 100644 --- a/content/en/functions/RenderString.md +++ b/content/en/functions/RenderString.md @@ -1,15 +1,15 @@ --- title: .RenderString -description: sRenders markup to HTML. +description: Renders markup to HTML. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .RenderString MARKUP [OPTIONS] +function: + aliases: [] + returnType: template.HTML + signatures: ['.RenderString MARKUP [OPTIONS]'] --- `.RenderString` is a method on `Page` that renders some markup to HTML using the content renderer defined for that page (if not set in the options). @@ -32,4 +32,4 @@ Some examples: {{ "/italic org mode/" | $p.RenderString $optOrg }} ``` -{{< new-in "0.93.0" >}} **Note**: [markdownify](/functions/markdownify/) uses this function in order to support [Render Hooks](/getting-started/configuration-markup/#markdown-render-hooks). +{{< new-in "0.93.0" >}} **Note**: [markdownify](/functions/transform/markdownify) uses this function in order to support [Render Hooks](/getting-started/configuration-markup/#markdown-render-hooks). diff --git a/content/en/functions/scratch.md b/content/en/functions/Scratch.md similarity index 96% rename from content/en/functions/scratch.md rename to content/en/functions/Scratch.md index 5836ca225..0640d6bcc 100644 --- a/content/en/functions/scratch.md +++ b/content/en/functions/Scratch.md @@ -2,15 +2,17 @@ title: .Scratch description: Acts as a "scratchpad" to store and manipulate data. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: +function: + aliases: [] + returnType: + signatures: [] +relatedFunctions: - .Store - .Scratch -signature: aliases: [/extras/scratch/,/doc/scratch/] --- @@ -74,7 +76,7 @@ Get the value of a given key. Add a given value to existing value(s) of the given key. -For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be [appended](/functions/append/) to that list. +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be [appended](/functions/collections/append/) to that list. ```go-html-template {{ $scratch.Add "greetings" "Hello" }} diff --git a/content/en/functions/store.md b/content/en/functions/Store.md similarity index 97% rename from content/en/functions/store.md rename to content/en/functions/Store.md index a9640a08a..49b38188b 100644 --- a/content/en/functions/store.md +++ b/content/en/functions/Store.md @@ -2,15 +2,17 @@ title: .Store description: Returns a Scratch that is not reset on server rebuilds. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: -relatedFuncs: +function: + aliases: [] + returnType: + signatures: [] +relatedFunctions: - .Store - .Scratch -signature: --- The `.Store` method on `.Page` returns a [Scratch] to store and manipulate data. In contrast to the `.Scratch` method, this Scratch is not reset on server rebuilds. diff --git a/content/en/functions/Unix.md b/content/en/functions/Unix.md new file mode 100644 index 000000000..ed49b72b5 --- /dev/null +++ b/content/en/functions/Unix.md @@ -0,0 +1,36 @@ +--- +title: .Unix +description: Converts a time.Time value to the number of seconds elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970. +categories: [functions] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: int64 + signatures: + - .Unix + - .UnixMilli + - .UnixMicro + - .UnixNano +relatedFunctions: [] +--- + +The `Milli`, `Micro`, and `Nano` variants return the number of milliseconds, microseconds, and nanoseconds (respectively) elapsed since the Unix epoch. + +```go-html-template +.Date.Unix → 1637259694 +.ExpiryDate.Unix → 1672559999 +.Lastmod.Unix → 1637361786 +.PublishDate.Unix → 1637421261 + +("1970-01-01T00:00:00-00:00" | time.AsTime).Unix → 0 +("1970-01-01T00:00:42-00:00" | time.AsTime).Unix → 42 +("1970-04-11T01:48:29-08:00" | time.AsTime).Unix → 8675309 +("2026-05-02T20:09:31-07:00" | time.AsTime).Unix → 1777777771 + +now.Unix → 1637447841 +now.UnixMilli → 1637447841347 +now.UnixMicro → 1637447841347378 +now.UnixNano → 1637447841347378799 +``` diff --git a/content/en/functions/_common/go-template-functions.md b/content/en/functions/_common/go-template-functions.md new file mode 100644 index 000000000..b8722743e --- /dev/null +++ b/content/en/functions/_common/go-template-functions.md @@ -0,0 +1,3 @@ +See Go's [text/template] documentation for more details. + +[text/template]: https://pkg.go.dev/text/template diff --git a/content/en/functions/common/index.md b/content/en/functions/_common/index.md similarity index 100% rename from content/en/functions/common/index.md rename to content/en/functions/_common/index.md diff --git a/content/en/functions/_common/locales.md b/content/en/functions/_common/locales.md new file mode 100644 index 000000000..259231cbf --- /dev/null +++ b/content/en/functions/_common/locales.md @@ -0,0 +1,3 @@ +Localization of dates, currencies, numbers, and percentages is performed by the [gohugoio/locales] package. The language tag of the current site must match one of the listed locales. + +[gohugoio/locales]: https://github.com/gohugoio/locales diff --git a/content/en/functions/common/regular-expressions.md b/content/en/functions/_common/regular-expressions.md similarity index 100% rename from content/en/functions/common/regular-expressions.md rename to content/en/functions/_common/regular-expressions.md diff --git a/content/en/functions/_common/time-layout-string.md b/content/en/functions/_common/time-layout-string.md new file mode 100644 index 000000000..40932f8cf --- /dev/null +++ b/content/en/functions/_common/time-layout-string.md @@ -0,0 +1,42 @@ +Format a `time.Time` value based on [Go's reference time]: + +[Go's reference time]: https://pkg.go.dev/time#pkg-constants + +```text {copy=false} +Mon Jan 2 15:04:05 MST 2006 +``` + +Create a format string using these components: + +Description|Valid components +:--|:-- +Year|`"2006" "06"` +Month|`"Jan" "January" "01" "1"` +Day of the week|`"Mon" "Monday"` +Day of the month|`"2" "_2" "02"` +Day of the year|`"__2" "002"` +Hour|`"15" "3" "03"` +Minute|`"4" "04"` +Second|`"5" "05"` +AM/PM mark|`"PM"` +Time zone offsets|`"-0700" "-07:00" "-07" "-070000" "-07:00:00"` + +Replace the sign in the format string with a Z to print Z instead of an offset for the UTC zone. + +Description|Valid components +:--|:-- +Time zone offsets|`"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"` + +```go-html-template +{{ $t := "2023-01-27T23:44:58-08:00" }} +{{ $t = time.AsTime $t }} +{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }} + +{{ $t }} → Jan 27, 2023 11:44 PM -08:00 +``` + +Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_. + +Strings such as `-07:00` and `+01:00` are not time zones. They are time zone _offsets_. + +A time zone is a geographic area with the same local time. For example, the time zone abbreviated by `PST` and `PDT` (depending on Daylight Savings Time) is `America/Los_Angeles`. diff --git a/content/en/functions/float.md b/content/en/functions/cast/ToFloat.md similarity index 83% rename from content/en/functions/float.md rename to content/en/functions/cast/ToFloat.md index f5a409839..acf70bc43 100644 --- a/content/en/functions/float.md +++ b/content/en/functions/cast/ToFloat.md @@ -1,19 +1,21 @@ --- -title: float +title: cast.ToFloat +linkTitle: float description: Casts a value to a decimal (base 10) floating point value. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: cast -relatedFuncs: +function: + aliases: [float] + returnType: float64 + signatures: [cast.ToFloat INPUT] +relatedFunctions: - cast.ToFloat - cast.ToInt - cast.ToString -signature: - - cast.ToFloat INPUT - - float INPUT +aliases: [/functions/float] --- With a decimal (base 10) input: diff --git a/content/en/functions/int.md b/content/en/functions/cast/ToInt.md similarity index 86% rename from content/en/functions/int.md rename to content/en/functions/cast/ToInt.md index feab3da09..b4a37cb6c 100644 --- a/content/en/functions/int.md +++ b/content/en/functions/cast/ToInt.md @@ -1,19 +1,21 @@ --- -title: int +title: cast.ToInt +linkTitle: int description: Casts a value to a decimal (base 10) integer. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: cast -relatedFuncs: +function: + aliases: [int] + returnType: int + signatures: [cast.ToInt INPUT] +relatedFunctions: - cast.ToFloat - cast.ToInt - cast.ToString -signature: - - cast.ToInt INPUT - - int INPUT +aliases: [/functions/int] --- With a decimal (base 10) input: diff --git a/content/en/functions/string.md b/content/en/functions/cast/ToString.md similarity index 84% rename from content/en/functions/string.md rename to content/en/functions/cast/ToString.md index 341a3a89c..d677ecdbf 100644 --- a/content/en/functions/string.md +++ b/content/en/functions/cast/ToString.md @@ -1,19 +1,21 @@ --- -title: string +title: cast.ToString +linkTitle: string description: Cast a value to a string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: cast -relatedFuncs: +function: + aliases: [string] + returnType: string + signatures: [cast.ToString INPUT] +relatedFunctions: - cast.ToFloat - cast.ToInt - cast.ToString -signature: - - cast.ToString INPUT - - string INPUT +aliases: [/functions/string] --- With a decimal (base 10) input: diff --git a/content/en/functions/after.md b/content/en/functions/collections/After.md similarity index 80% rename from content/en/functions/after.md rename to content/en/functions/collections/After.md index f121ca302..e27c1507f 100644 --- a/content/en/functions/after.md +++ b/content/en/functions/collections/After.md @@ -1,22 +1,24 @@ --- -title: after +title: collections.After +linkTitle: after description: Slices an array to the items after the Nth item. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [after] + returnType: any + signatures: [collections.After INDEX COLLECTION] +relatedFunctions: - collections.After - collections.First - collections.Last -signature: - - collections.After INDEX COLLECTION - - after INDEX COLLECTION +aliases: [/functions/after] --- -The following shows `after` being used in conjunction with the [`slice` function][slice]: +The following shows `after` being used in conjunction with the [`slice`]function: ```go-html-template {{ $data := slice "one" "two" "three" "four" }} @@ -28,7 +30,7 @@ The following shows `after` being used in conjunction with the [`slice` function ## Example of `after` with `first`: 2nd–4th most recent articles -You can use `after` in combination with the [`first` function] and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page] to show only two rows: +You can use `after` in combination with the [`first`] function and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page] to show only two rows: 1. The top row is titled "Featured" and shows only the most recently published article (i.e. by `publishdate` in the content files' front matter). 2. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles. @@ -58,7 +60,7 @@ You can use `after` in combination with the [`first` function] and Hugo's [power {{ end }} {{< /code >}} -[`first` function]: /functions/first/ -[list/section page]: /templates/section-templates/ +[`first`]: /functions/collections/first +[list/section page]: /templates/section-templates [lists]: /templates/lists/#order-content -[slice]: /functions/slice/ +[`slice`]: /functions/collections/slice/ diff --git a/content/en/functions/append.md b/content/en/functions/collections/Append.md similarity index 89% rename from content/en/functions/append.md rename to content/en/functions/collections/Append.md index 913ff322d..31657288f 100644 --- a/content/en/functions/append.md +++ b/content/en/functions/collections/Append.md @@ -1,21 +1,23 @@ --- -title: append +title: collections.Append +linkTitle: append description: Appends one or more elements to a slice and returns the resulting slice. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [append] + returnType: any + signatures: + - COLLECTION | collections.Append ELEMENT [ELEMENT]... + - COLLECTION | collections.Append COLLECTION +relatedFunctions: - collections.Append - collections.Merge - collections.Slice -signature: - - COLLECTION | collections.Append ELEMENT [ELEMENT]... - - COLLECTION | collections.Append COLLECTION - - COLLECTION | append ELEMENT [ELEMENT]... - - COLLECTION | append COLLECTION +aliases: [/functions/append] --- This function appends all elements, excluding the last, to the last element. This allows [pipe](/getting-started/glossary/#pipeline) constructs as shown below. diff --git a/content/en/functions/apply.md b/content/en/functions/collections/Apply.md similarity index 76% rename from content/en/functions/apply.md rename to content/en/functions/collections/Apply.md index 95d8b6231..d7401908a 100644 --- a/content/en/functions/apply.md +++ b/content/en/functions/collections/Apply.md @@ -1,28 +1,30 @@ --- -title: apply +title: collections.Apply +linkTitle: apply description: Given an array or slice, `apply` returns a new slice with a function applied over it. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [apply] + returnType: any + signatures: ['collections.Apply COLLECTION FUNCTION [PARAM...]'] +relatedFunctions: - collections.Apply - collections.Delimit - collections.In - collections.Reverse - collections.Seq - collections.Slice -signature: - - collections.Apply COLLECTION FUNCTION [PARAM...] - - apply COLLECTION FUNCTION [PARAM...] +aliases: [/functions/apply] --- `apply` expects at least three arguments, depending on the function being applied. 1. The first argument is the sequence to operate on. -2. The second argument is the name of the function as a string, which must be the name of a valid [Hugo function][functions]. +2. The second argument is the name of the function as a string, which must be the name of a valid [template function]. 3. After that, the arguments to the applied function are provided, with the string `"."` standing in for each element of the sequence the function is to be applied against. Here is an example of a content file with `names:` as a front matter field: @@ -44,13 +46,13 @@ Which will result in the following: "derek-perkins", "joe-bergevin", "tanner-linsley" ``` -This is *roughly* equivalent to using the following with [range]: +This is *roughly* equivalent to using the following with [`range`]: ```go-html-template {{ range .Params.names }}{{ . | urlize }}{{ end }} ``` -However, it is not possible to provide the output of a range to the [`delimit` function][delimit], so you need to `apply` it. +However, it is not possible to provide the output of a range to the [`delimit`]function, so you need to `apply` it. If you have `post-tag-list.html` and `post-tag-link.html` as [partials], you *could* use the following snippets, respectively: @@ -92,7 +94,7 @@ This first version of `layouts/partials/post-tag-list.html` separates all of the {{ end }} ``` -Now in the completed version, you can sort the tags, convert the tags to links with `layouts/partials/post-tag-link.html`, [chomp] off stray newlines, and join the tags together in a delimited list for presentation. Here is an even DRYer version of the preceding example: +Now in the completed version, you can sort the tags, convert the tags to links with `layouts/partials/post-tag-link.html`, [`chomp`] stray newlines, and join the tags together in a delimited list for presentation. Here is an even DRYer version of the preceding example: {{< code file="layouts/partials/post-tag-list.html" >}} {{ with .Params.tags }} @@ -107,8 +109,7 @@ Now in the completed version, you can sort the tags, convert the tags to links w `apply` does not work when receiving the sequence as an argument through a pipeline. {{% /note %}} -[chomp]: /functions/chomp/ "See documentation for the chomp function" -[delimit]: /functions/delimit/ "See documentation for the delimit function" -[functions]: /functions/ "See the full list of Hugo functions to see what can be passed as an argument to the apply function." -[partials]: /templates/partials/ -[range]: /functions/range/ "Learn the importance of the range function, a fundamental keyword in both Hugo templates and the Go programming language." +[`chomp`]: /functions/strings/chomp/ +[`delimit`]: /functions/collections/delimit/ +[template function]: /functions/ +[`range`]: /functions/go-template/range/ diff --git a/content/en/functions/complement.md b/content/en/functions/collections/Complement.md similarity index 87% rename from content/en/functions/complement.md rename to content/en/functions/collections/Complement.md index 2c93b68a6..28b7ded3d 100644 --- a/content/en/functions/complement.md +++ b/content/en/functions/collections/Complement.md @@ -1,19 +1,22 @@ --- -title: complement +title: collections.Complement +linkTitle: complement description: Returns the elements of the last collection that are not in any of the others. categories: [functions] +keywords: [] menu: docs: parent: functions -namespace: collections -relatedFuncs: +function: + aliases: [complement] + returnType: any + signatures: ['collections.Complement COLLECTION [COLLECTION]...'] +relatedFunctions: - collections.Complement - collections.Intersect - collections.SymDiff - collections.Union -signature: - - collections.Complement COLLECTION [COLLECTION]... - - complement COLLECTION [COLLECTION]... +aliases: [/functions/complement] --- To find the elements within `$c3` that do not exist in `$c1` or `$c2`: @@ -61,7 +64,7 @@ To list everything except blog articles (`blog`) and frequently asked questions {{% note %}} Although the example above demonstrates the `complement` function, you could use the [`where`] function as well: -[`where`]: /functions/where/ +[`where`]: /functions/collections/where {{% /note %}} ```go-html-template diff --git a/content/en/functions/delimit.md b/content/en/functions/collections/Delimit.md similarity index 77% rename from content/en/functions/delimit.md rename to content/en/functions/collections/Delimit.md index 5d6cb42df..0fc3ef537 100644 --- a/content/en/functions/delimit.md +++ b/content/en/functions/collections/Delimit.md @@ -1,13 +1,17 @@ --- -title: delimit +title: collections.Delimit +linkTitle: delimit description: Loops through any array, slice, or map and returns a string of all the values separated by a delimiter. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [delimit] + returnType: template.HTML + signatures: ['collections.Delimit COLLECTION DELIMITER [LAST]'] +relatedFunctions: - collections.Apply - collections.Delimit - collections.In @@ -15,9 +19,7 @@ relatedFuncs: - collections.Seq - collections.Slice - strings.Split -signature: - - collections.Delimit COLLECTION DELIMITER [LAST] - - delimit COLLECTION DELIMITER [LAST] +aliases: [/functions/delimit] --- Delimit a slice: diff --git a/content/en/functions/dict.md b/content/en/functions/collections/Dictionary.md similarity index 90% rename from content/en/functions/dict.md rename to content/en/functions/collections/Dictionary.md index 50584caaf..28c387726 100644 --- a/content/en/functions/dict.md +++ b/content/en/functions/collections/Dictionary.md @@ -1,21 +1,23 @@ --- -title: dict +title: collections.Dictionary +linkTitle: dict description: Creates a map from a list of key and value pairs. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [dict] + returnType: mapany + signatures: ['collections.Dictionary KEY VALUE [KEY VALUE]...'] +relatedFunctions: - collections.Dictionary - collections.Group - collections.Index - collections.IsSet - collections.Where -signature: - - collections.Dictionary KEY VALUE [KEY VALUE]... - - dict KEY VALUE [KEY VALUE]... +aliases: [/functions/dict] --- `dict` is especially useful for passing more than one value to a partial template. diff --git a/content/en/functions/echoparam.md b/content/en/functions/collections/EchoParam.md similarity index 78% rename from content/en/functions/echoparam.md rename to content/en/functions/collections/EchoParam.md index a45d03b62..7617eedd9 100644 --- a/content/en/functions/echoparam.md +++ b/content/en/functions/collections/EchoParam.md @@ -1,16 +1,18 @@ --- -title: echoParam +title: collections.EchoParam +linkTitle: echoParam description: Prints a parameter if it is set. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: [] -signature: - - collections.EchoParam COLLECTION KEY - - echoParam COLLECTION KEY +function: + aliases: [echoParam] + returnType: any + signatures: [collections.EchoParam COLLECTION KEY] +relatedFunctions: [] +aliases: [/functions/echoparam] --- For example, consider this site configuration: diff --git a/content/en/functions/first.md b/content/en/functions/collections/First.md similarity index 69% rename from content/en/functions/first.md rename to content/en/functions/collections/First.md index f906da962..ddb045382 100644 --- a/content/en/functions/first.md +++ b/content/en/functions/collections/First.md @@ -1,19 +1,21 @@ --- -title: first +title: collections.First +linkTitle: first description: Slices an array to the first N elements. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [first] + returnType: any + signatures: [collections.First LIMIT COLLECTION] +relatedFunctions: - collections.After - collections.First - collections.Last -signature: - - collections.First LIMIT COLLECTION - - first LIMIT COLLECTION +aliases: [/functions/first] --- `first` works in a similar manner to the [`limit` keyword in @@ -34,9 +36,9 @@ elements. It takes the array and number of elements as input. ## `first` and `where` Together -Using `first` and [`where`][wherefunction] together can be very -powerful. Below snippet gets a list of posts only from [**main -sections**][mainsections], sorts it by the `title` parameter, and then +Using `first` and [`where`] together can be very +powerful. Below snippet gets a list of posts only from [main +sections], sorts it by the `title` parameter, and then ranges through only the first 5 posts in that list: {{< code file="first-and-where-together.html" >}} @@ -47,5 +49,5 @@ ranges through only the first 5 posts in that list: [limitkeyword]: https://www.techonthenet.com/sql/select_limit.php -[wherefunction]: /functions/where/ -[mainsections]: /functions/where/#mainsections +[`where`]: /functions/collections/where +[main sections]: /functions/collections/where#mainsections diff --git a/content/en/functions/group.md b/content/en/functions/collections/Group.md similarity index 80% rename from content/en/functions/group.md rename to content/en/functions/collections/Group.md index bd7f71091..29220f1f7 100644 --- a/content/en/functions/group.md +++ b/content/en/functions/collections/Group.md @@ -1,21 +1,23 @@ --- -title: group -description: "`group` groups a list of pages." +title: collections.Group +linkTitle: group +description: Groups a list of pages. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [group] + returnType: any + signatures: [PAGES | collections.Group KEY] +relatedFunctions: - collections.Dictionary - collections.Group - collections.Index - collections.IsSet - collections.Where -signature: - - PAGES | collections.Group KEY - - PAGES | group KEY +aliases: [/functions/group] --- {{< code file="layouts/partials/groups.html" >}} diff --git a/content/en/functions/collections/In.md b/content/en/functions/collections/In.md new file mode 100644 index 000000000..57ffbd653 --- /dev/null +++ b/content/en/functions/collections/In.md @@ -0,0 +1,38 @@ +--- +title: collections.In +linkTitle: in +description: Reports whether an element is in an array or slice, or if a substring is in a string. +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [in] + returnType: bool + signatures: [collections.In SET ITEM] +relatedFunctions: + - collections.Slice +aliases: [/functions/in] +--- + + + +```go-html-template +{{ $s := slice "a" "b" "c" }} +{{ in $s "b" }} → true +``` + +```go-html-template +{{ $s := slice 1 2 3 }} +{{ in $s 2 }} → true +``` + +```go-html-template +{{ $s := slice 1.11 2.22 3.33 }} +{{ in $s 2.22 }} → true +``` + +```go-html-template +{{ $s := "abc" }} +{{ in $s "b" }} → true +``` diff --git a/content/en/functions/index-function.md b/content/en/functions/collections/IndexFunction.md similarity index 92% rename from content/en/functions/index-function.md rename to content/en/functions/collections/IndexFunction.md index 1a9fd9dba..cd063f36e 100644 --- a/content/en/functions/index-function.md +++ b/content/en/functions/collections/IndexFunction.md @@ -1,25 +1,26 @@ --- -title: index +title: collections.Index +linkTitle: index description: Looks up the index(es) or key(s) of the data structure passed into it. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [index] + returnType: any + signatures: + - collections.Index COLLECTION INDEXES + - collections.Index COLLECTION KEYS +relatedFunctions: - collections.Dictionary - collections.EchoParam - collections.Group - collections.Index - collections.IsSet - collections.Where -signature: - - collections.Index COLLECTION INDEXES - - collections.Index COLLECTION KEYS - - index COLLECTION INDEXES - - index COLLECTION KEYS -aliases: [/functions/index/] +aliases: [/functions/index,/functions/index-function] --- The `index` functions returns the result of indexing its first argument by the following arguments. Each indexed item must be a map or a slice, e.g.: diff --git a/content/en/functions/intersect.md b/content/en/functions/collections/Intersect.md similarity index 77% rename from content/en/functions/intersect.md rename to content/en/functions/collections/Intersect.md index 0816fd1b6..6a2c131b4 100644 --- a/content/en/functions/intersect.md +++ b/content/en/functions/collections/Intersect.md @@ -1,19 +1,22 @@ --- -title: intersect +title: collections.Intersect +linkTitle: intersect description: Returns the common elements of two arrays or slices, in the same order as the first array. categories: [functions] +keywords: [] menu: docs: parent: functions -namespace: collections -relatedFuncs: +function: + aliases: [intersect] + returnType: any + signatures: [collections.Intersect SET1 SET2] +relatedFunctions: - collections.Complement - collections.Intersect - collections.SymDiff - collections.Union -signature: - - collections.Intersect SET1 SET2 - - intersect SET1 SET2 +aliases: [/functions/intersect] --- A useful example is to use it as `AND` filters when combined with where: @@ -27,7 +30,7 @@ A useful example is to use it as `AND` filters when combined with where: The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters. -See [union](/functions/union) for `OR`. +See [union](/functions/collections/union) for `OR`. [partials]: /templates/partials/ diff --git a/content/en/functions/isset.md b/content/en/functions/collections/IsSet.md similarity index 81% rename from content/en/functions/isset.md rename to content/en/functions/collections/IsSet.md index 469ce9b02..93fb9f8f6 100644 --- a/content/en/functions/isset.md +++ b/content/en/functions/collections/IsSet.md @@ -1,21 +1,23 @@ --- -title: isset -description: Returns true if the key exists within the collection. +title: collections.IsSet +linkTitle: isset +description: Reports whether the key exists within the collection. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [isset] + returnType: bool + signatures: [collections.IsSet COLLECTION KEY] +relatedFunctions: - collections.Dictionary - collections.Group - collections.Index - collections.IsSet - collections.Where -signature: - - collections.IsSet COLLECTION KEY - - isset COLLECTION KEY +aliases: [/functions/isset] --- For example, consider this site configuration: diff --git a/content/en/functions/keyvals.md b/content/en/functions/collections/KeyVals.md similarity index 75% rename from content/en/functions/keyvals.md rename to content/en/functions/collections/KeyVals.md index 1fc2f1f5e..f3e0c559d 100644 --- a/content/en/functions/keyvals.md +++ b/content/en/functions/collections/KeyVals.md @@ -1,17 +1,18 @@ --- -title: keyVals +title: collections.KeyVals +linkTitle: keyVals description: Returns a KeyVals struct. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: [] -signature: - - collections.KeyVals KEY VALUES... - - keyVals KEY VALUES... - +function: + aliases: [keyVals] + returnType: KeyValues + signatures: [collections.KeyVals KEY VALUES...] +relatedFunctions: [] +aliases: [/functions/keyvals] --- The primary application for this function is the definition of the `namedSlices` parameter in the options map passed to the `.Related` method on the `Page` object. diff --git a/content/en/functions/last.md b/content/en/functions/collections/Last.md similarity index 61% rename from content/en/functions/last.md rename to content/en/functions/collections/Last.md index 1cf7f21b5..3f8496354 100644 --- a/content/en/functions/last.md +++ b/content/en/functions/collections/Last.md @@ -1,19 +1,21 @@ --- -title: last +title: collections.Last +linkTitle: last description: Slices an array to the last N elements. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [last] + returnType: any + signatures: [collections.Last INDEX COLLECTION] +relatedFunctions: - collections.After - collections.First - collections.Last -signature: - - collections.Last INDEX COLLECTION - - last INDEX COLLECTION +aliases: [/functions/last] --- ```go-html-template diff --git a/content/en/functions/merge.md b/content/en/functions/collections/Merge.md similarity index 81% rename from content/en/functions/merge.md rename to content/en/functions/collections/Merge.md index 13801c05d..908f1738a 100644 --- a/content/en/functions/merge.md +++ b/content/en/functions/collections/Merge.md @@ -1,18 +1,20 @@ --- -title: merge -description: "Returns the result of merging two or more maps." +title: collections.Merge +linkTitle: merge +description: Returns the result of merging two or more maps. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [merge] + returnType: any + signatures: [collections.Merge MAP MAP...] +relatedFunctions: - collections.Append - collections.Merge -signature: - - collections.Merge MAP MAP... - - merge MAP MAP... +aliases: [/functions/merge] --- Returns the result of merging two or more maps from left to right. If a key already exists, `merge` updates its value. If a key is absent, `merge` inserts the value under the new key. @@ -68,5 +70,5 @@ Example 4 ``` {{% note %}} -Regardless of depth, merging only applies to maps. For slices, use [append](/functions/append). +Regardless of depth, merging only applies to maps. For slices, use [append](/functions/collections/append). {{% /note %}} diff --git a/content/en/functions/collections/NewScratch.md b/content/en/functions/collections/NewScratch.md new file mode 100644 index 000000000..0df90bb96 --- /dev/null +++ b/content/en/functions/collections/NewScratch.md @@ -0,0 +1,22 @@ +--- +title: collections.NewScratch +linkTitle: newScratch +description: Creates a new Scratch which can be used to store values in a thread safe way. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [newScratch] + returnType: Scratch + signatures: [collections.NewScratch ] +relatedFunctions: [] +--- + +```go-html-template +{{ $scratch := newScratch }} +{{ $scratch.Add "b" 2 }} +{{ $scratch.Add "b" 2 }} +{{ $scratch.Get "b" }} → 4 +``` diff --git a/content/en/functions/querify.md b/content/en/functions/collections/Querify.md similarity index 76% rename from content/en/functions/querify.md rename to content/en/functions/collections/Querify.md index 59177f14f..c94d51133 100644 --- a/content/en/functions/querify.md +++ b/content/en/functions/collections/Querify.md @@ -1,20 +1,22 @@ --- -title: querify +title: collections.Querify +linkTitle: querify description: Takes a set or slice of key-value pairs and returns a query string to be appended to URLs. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [querify] + returnType: string + signatures: + - collections.Querify KEY VALUE [KEY VALUE]... + - collections.Querify COLLECTION +relatedFunctions: - collections.Querify - urlquery -signature: - - collections.Querify KEY VALUE [KEY VALUE]... - - collections.Querify COLLECTION - - querify KEY VALUE [KEY VALUE]... - - querify COLLECTION +aliases: [/functions/querify] --- `querify` takes a set or slice of key-value pairs and returns a [query string](https://en.wikipedia.org/wiki/Query_string) that can be appended to a URL. diff --git a/content/en/functions/collections.Reverse.md b/content/en/functions/collections/Reverse.md similarity index 71% rename from content/en/functions/collections.Reverse.md rename to content/en/functions/collections/Reverse.md index 41d34e44a..521adc6f2 100644 --- a/content/en/functions/collections.Reverse.md +++ b/content/en/functions/collections/Reverse.md @@ -2,20 +2,22 @@ title: collections.Reverse description: Reverses the order of a collection. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [] + returnType: any + signatures: [collections.Reverse COLLECTION] +relatedFunctions: - collections.Apply - collections.Delimit - collections.In - collections.Reverse - collections.Seq - collections.Slice -signature: - - collections.Reverse COLLECTION +aliases: [/functions/collections.reverse] --- diff --git a/content/en/functions/seq.md b/content/en/functions/collections/Seq.md similarity index 69% rename from content/en/functions/seq.md rename to content/en/functions/collections/Seq.md index 342250e39..65ff1432f 100644 --- a/content/en/functions/seq.md +++ b/content/en/functions/collections/Seq.md @@ -1,26 +1,27 @@ --- -title: seq +title: collections.Seq +linkTitle: seq description: Returns a slice of integers. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [seq] + returnType: '[]int' + signatures: + - collections.Seq LAST + - collections.Seq FIRST LAST + - collections.Seq FIRST INCREMENT LAST +relatedFunctions: - collections.Apply - collections.Delimit - collections.In - collections.Reverse - collections.Seq - collections.Slice -signature: - - collections.Seq LAST - - collections.Seq FIRST LAST - - collections.Seq FIRST INCREMENT LAST - - seq LAST - - seq FIRST LAST - - seq FIRST INCREMENT LAST +aliases: [/functions/seq] --- ```go-html-template diff --git a/content/en/functions/shuffle.md b/content/en/functions/collections/Shuffle.md similarity index 68% rename from content/en/functions/shuffle.md rename to content/en/functions/collections/Shuffle.md index d07b3d2ac..8388d5332 100644 --- a/content/en/functions/shuffle.md +++ b/content/en/functions/collections/Shuffle.md @@ -1,24 +1,25 @@ --- -title: shuffle +title: collections.Shuffle +linkTitle: shuffle description: Returns a random permutation of a given array or slice. keywords: [ordering] categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [shuffle] + returnType: any + signatures: [collections.Shuffle COLLECTION] +relatedFunctions: - collections.Reverse - collections.Shuffle - collections.Sort - collections.Uniq -signature: - - collections.Shuffle COLLECTION - - shuffle COLLECTION +aliases: [/functions/shuffle] --- - ```go-html-template {{ shuffle (seq 1 2 3) }} → [3 1 2] {{ shuffle (slice "a" "b" "c") }} → [b a c] diff --git a/content/en/functions/slice.md b/content/en/functions/collections/Slice.md similarity index 50% rename from content/en/functions/slice.md rename to content/en/functions/collections/Slice.md index f8a05c57e..a30800ed3 100644 --- a/content/en/functions/slice.md +++ b/content/en/functions/collections/Slice.md @@ -1,13 +1,17 @@ --- -title: slice +title: collections.Slice +linkTitle: slice description: Creates a slice (array) of all passed arguments. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [slice] + returnType: any + signatures: [collections.Slice ITEM...] +relatedFunctions: - collections.Append - collections.Apply - collections.Delimit @@ -15,19 +19,12 @@ relatedFuncs: - collections.Reverse - collections.Seq - collections.Slice -signature: - - collections.Slice ITEM... - - slice ITEM... +aliases: [/functions/slice] --- One use case is the concatenation of elements in combination with the [`delimit` function]: -{{< code file="slice.html" >}} -{{ $sliceOfStrings := slice "foo" "bar" "buzz" }} - -{{ delimit ($sliceOfStrings) ", " }} - -{{< /code >}} - - -[`delimit` function]: /functions/delimit/ +```go-html-template +{{ $s := slice "a" "b" "c" }} +{{ $s }} → [a b c] +``` diff --git a/content/en/functions/sort.md b/content/en/functions/collections/Sort.md similarity index 94% rename from content/en/functions/sort.md rename to content/en/functions/collections/Sort.md index d0c722b0b..bb0f82cde 100644 --- a/content/en/functions/sort.md +++ b/content/en/functions/collections/Sort.md @@ -1,20 +1,22 @@ --- -title: sort +title: collections.Sort +linkTitle: sort description: Sorts slices, maps, and page collections. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [sort] + returnType: any + signatures: ['collections.Sort COLLECTION [KEY] [ORDER]'] +relatedFunctions: - collections.Reverse - collections.Shuffle - collections.Sort - collections.Uniq -signature: - - collections.Sort COLLECTION [KEY] [ORDER] - - sort COLLECTION [KEY] [ORDER] +aliases: [/functions/sort] --- The `KEY` is optional when sorting slices in ascending order, otherwise it is required. When sorting slices, use the literal `value` in place of the `KEY`. See examples below. diff --git a/content/en/functions/collections/SymDiff.md b/content/en/functions/collections/SymDiff.md new file mode 100644 index 000000000..ea9f20123 --- /dev/null +++ b/content/en/functions/collections/SymDiff.md @@ -0,0 +1,28 @@ +--- +title: collections.SymDiff +linkTitle: symdiff +description: Returns the symmetric difference of two collections. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [symdiff] + returnType: any + signatures: [COLLECTION | collections.SymDiff COLLECTION] +relatedFunctions: + - collections.Complement + - collections.Intersect + - collections.SymDiff + - collections.Union +aliases: [/functions/symdiff] +--- + +Example: + +```go-html-template +{{ slice 1 2 3 | symdiff (slice 3 4) }} → [1 2 4] +``` + +Also see https://en.wikipedia.org/wiki/Symmetric_difference diff --git a/content/en/functions/union.md b/content/en/functions/collections/Union.md similarity index 84% rename from content/en/functions/union.md rename to content/en/functions/collections/Union.md index a20610acb..119da6fb4 100644 --- a/content/en/functions/union.md +++ b/content/en/functions/collections/Union.md @@ -1,19 +1,22 @@ --- -title: union +title: collections.Union +linkTitle: union description: Given two arrays or slices, returns a new array that contains the elements or objects that belong to either or both arrays/slices. categories: [functions] +keywords: [] menu: docs: parent: functions -namespace: collections -relatedFuncs: +function: + aliases: [union] + returnType: any + signatures: [collections.Union SET1 SET2] +relatedFunctions: - collections.Complement - collections.Intersect - collections.SymDiff - collections.Union -signature: - - collections.Union SET1 SET2 - - union SET1 SET2 +aliases: [/functions/union] --- Given two arrays (or slices) A and B, this function will return a new array that contains the elements or objects that belong to either A or to B or to both. The elements supported are strings, integers, and floats (only float64). @@ -44,4 +47,4 @@ This is also very useful to use as `OR` filters when combined with where: The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters. -See [intersect](/functions/intersect) for `AND`. +See [intersect](/functions/collections/intersect) for `AND`. diff --git a/content/en/functions/uniq.md b/content/en/functions/collections/Uniq.md similarity index 65% rename from content/en/functions/uniq.md rename to content/en/functions/collections/Uniq.md index 88be1cbd3..1b0a8f8f4 100644 --- a/content/en/functions/uniq.md +++ b/content/en/functions/collections/Uniq.md @@ -1,20 +1,22 @@ --- -title: uniq +title: collections.Uniq +linkTitle: uniq description: Takes in a slice or array and returns a slice with duplicate elements removed. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [uniq] + returnType: any + signatures: [collections.Uniq COLLECTION] +relatedFunctions: - collections.Reverse - collections.Shuffle - collections.Sort - collections.Uniq -signature: - - collections.Uniq COLLECTION - - uniq COLLECTION +aliases: [/functions/uniq] --- diff --git a/content/en/functions/where.md b/content/en/functions/collections/Where.md similarity index 94% rename from content/en/functions/where.md rename to content/en/functions/collections/Where.md index 6a076d1a1..df6cec89f 100644 --- a/content/en/functions/where.md +++ b/content/en/functions/collections/Where.md @@ -1,21 +1,23 @@ --- -title: where +title: collections.Where +linkTitle: where description: Filters an array to only the elements containing a matching value for a given field. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: collections -relatedFuncs: +function: + aliases: [where] + returnType: any + signatures: ['collections.Where COLLECTION KEY [OPERATOR] MATCH'] +relatedFunctions: - collections.Dictionary - collections.Group - collections.Index - collections.IsSet - collections.Where -signature: - - collections.Where COLLECTION KEY [OPERATOR] MATCH - - where COLLECTION KEY [OPERATOR] MATCH +aliases: [/functions/where] toc: true --- @@ -122,7 +124,7 @@ This example matches pages where the "foo" parameter begins with "ab": {{ end }} ``` -{{% readfile file="/functions/common/regular-expressions.md" %}} +{{% readfile file="/functions/_common/regular-expressions.md" %}} ## Use `where` with `first` @@ -184,5 +186,5 @@ The user can override the default: mainSections = ["blog", "docs"] {{< /code-toggle >}} -[intersect]: /functions/intersect/ +[intersect]: /functions/collections/intersect [wherekeyword]: https://www.techonthenet.com/sql/where.php diff --git a/content/en/functions/cond.md b/content/en/functions/compare/Cond.md similarity index 87% rename from content/en/functions/cond.md rename to content/en/functions/compare/Cond.md index 62f2cfdb9..4b92a893c 100644 --- a/content/en/functions/cond.md +++ b/content/en/functions/compare/Cond.md @@ -1,18 +1,20 @@ --- -title: cond +title: compare.Conditional +linkTitle: cond description: Returns one of two arguments depending on the value of the control argument. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [cond] + returnType: any + signatures: [compare.Conditional CONTROL ARG1 ARG2] +relatedFunctions: - compare.Conditional - compare.Default -signature: - - compare.Conditional CONTROL ARG1 ARG2 - - cond CONTROL ARG1 ARG2 +aliases: [/functions/cond] --- The CONTROL argument is a boolean value that indicates whether the function should return ARG1 or ARG2. If CONTROL is `true`, the function returns ARG1. Otherwise, the function returns ARG2. diff --git a/content/en/functions/default.md b/content/en/functions/compare/Default.md similarity index 91% rename from content/en/functions/default.md rename to content/en/functions/compare/Default.md index 98cf55fbf..24ad37ef2 100644 --- a/content/en/functions/default.md +++ b/content/en/functions/compare/Default.md @@ -1,18 +1,20 @@ --- -title: default +title: compare.Default +linkTitle: default description: Allows setting a default value that can be returned if a first value is not set. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [default] + returnType: any + signatures: [compare.Default DEFAULT INPUT] +relatedFunctions: - compare.Conditional - compare.Default -signature: - - compare.Default DEFAULT INPUT - - default DEFAULT INPUT +aliases: [/functions/default] --- `default` checks whether a given value is set and returns a default value if it is not. *Set* in this context means different things depending on the data type: diff --git a/content/en/functions/eq.md b/content/en/functions/compare/Eq.md similarity index 70% rename from content/en/functions/eq.md rename to content/en/functions/compare/Eq.md index 02691d0a3..010fc51b3 100644 --- a/content/en/functions/eq.md +++ b/content/en/functions/compare/Eq.md @@ -1,22 +1,24 @@ --- -title: eq +title: compare.Eq +linkTitle: eq description: Returns the boolean truth of arg1 == arg2 || arg1 == arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [eq] + returnType: bool + signatures: ['compare.Eq ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Eq ARG1 ARG2 [ARG...] - - eq ARG1 ARG2 [ARG...] +aliases: [/functions/eq] --- ```go-html-template diff --git a/content/en/functions/ge.md b/content/en/functions/compare/Ge.md similarity index 75% rename from content/en/functions/ge.md rename to content/en/functions/compare/Ge.md index adb7ea785..6bb48dd00 100644 --- a/content/en/functions/ge.md +++ b/content/en/functions/compare/Ge.md @@ -1,22 +1,24 @@ --- -title: ge +title: compare.Ge +linkTitle: ge description: Returns the boolean truth of arg1 >= arg2 && arg1 >= arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [ge] + returnType: bool + signatures: ['compare.Ge ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Ge ARG1 ARG2 [ARG...] - - ge ARG1 ARG2 [ARG...] +aliases: [/functions/ge] --- ```go-html-template diff --git a/content/en/functions/gt.md b/content/en/functions/compare/Gt.md similarity index 75% rename from content/en/functions/gt.md rename to content/en/functions/compare/Gt.md index e147efcd9..4691718ef 100644 --- a/content/en/functions/gt.md +++ b/content/en/functions/compare/Gt.md @@ -1,22 +1,24 @@ --- -title: gt +title: compare.Gt +linkTitle: gt description: Returns the boolean truth of arg1 > arg2 && arg1 > arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [gt] + returnType: bool + signatures: ['compare.Gt ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Gt ARG1 ARG2 [ARG...] - - gt ARG1 ARG2 [ARG...] +aliases: [/functions/gt] --- ```go-html-template diff --git a/content/en/functions/le.md b/content/en/functions/compare/Le.md similarity index 75% rename from content/en/functions/le.md rename to content/en/functions/compare/Le.md index ec09e0111..792ea6ce6 100644 --- a/content/en/functions/le.md +++ b/content/en/functions/compare/Le.md @@ -1,22 +1,24 @@ --- -title: le +title: compare.Le +linkTitle: le description: Returns the boolean truth of arg1 <= arg2 && arg1 <= arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [le] + returnType: bool + signatures: ['compare.Le ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Le ARG1 ARG2 [ARG...] - - le ARG1 ARG2 [ARG...] +aliases: [/functions/le] --- ```go-html-template diff --git a/content/en/functions/lt.md b/content/en/functions/compare/Lt.md similarity index 75% rename from content/en/functions/lt.md rename to content/en/functions/compare/Lt.md index b083e75da..537c23b6f 100644 --- a/content/en/functions/lt.md +++ b/content/en/functions/compare/Lt.md @@ -1,22 +1,24 @@ --- -title: lt +title: compare.Lt +linkTitle: lt description: Returns the boolean truth of arg1 < arg2 && arg1 < arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: compare -relatedFuncs: +function: + aliases: [lt] + returnType: bool + signatures: ['compare.Lt ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Lt ARG1 ARG2 [ARG...] - - lt ARG1 ARG2 [ARG...] +aliases: [/functions/lt] --- ```go-html-template diff --git a/content/en/functions/ne.md b/content/en/functions/compare/Ne.md similarity index 68% rename from content/en/functions/ne.md rename to content/en/functions/compare/Ne.md index 9bcddd71b..412f43d49 100644 --- a/content/en/functions/ne.md +++ b/content/en/functions/compare/Ne.md @@ -1,21 +1,24 @@ --- -title: ne +title: compare.Ne +linkTitle: ne description: Returns the boolean truth of arg1 != arg2 && arg1 != arg3. categories: [functions] +keywords: [] menu: docs: parent: functions -namespace: compare -relatedFuncs: +function: + aliases: [ne] + returnType: bool + signatures: ['compare.Ne ARG1 ARG2 [ARG...]'] +relatedFunctions: - compare.Eq - compare.Ge - compare.Gt - compare.Le - compare.Lt - compare.Ne -signature: - - compare.Ne ARG1 ARG2 [ARG...] - - ne ARG1 ARG2 [ARG...] +aliases: [/functions/ne] --- ```go-html-template diff --git a/content/en/functions/countrunes.md b/content/en/functions/countrunes.md deleted file mode 100644 index fc2545604..000000000 --- a/content/en/functions/countrunes.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: countrunes -description: Determines the number of runes in a string excluding any whitespace. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: strings -relatedFuncs: - - len - - strings.Count - - strings.CountRunes - - strings.CountWords - - strings.RuneCount -signature: - - strings.CountRunes INPUT - - countrunes INPUT ---- - -In contrast with `countwords` function, which counts every word in a string, the `countrunes` function determines the number of runes in the content and excludes any whitespace. This has specific utility if you are dealing with CJK-like languages. - -```go-html-template -{{ "Hello, 世界" | countrunes }} - -``` - -[pagevars]: /variables/page/ diff --git a/content/en/functions/crypto.FNV32a.md b/content/en/functions/crypto/FNV32a.md similarity index 81% rename from content/en/functions/crypto.FNV32a.md rename to content/en/functions/crypto/FNV32a.md index 41d663e17..7a7fe303e 100644 --- a/content/en/functions/crypto.FNV32a.md +++ b/content/en/functions/crypto/FNV32a.md @@ -2,19 +2,21 @@ title: crypto.FNV32a description: Returns the FNV (Fowler–Noll–Vo) 32 bit hash of a given string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: crypto -relatedFuncs: +function: + aliases: [] + returnType: int + signatures: [crypto.FNV32a STRING] +relatedFunctions: - crypto.FNV32a - crypto.HMAC - crypto.MD5 - crypto.SHA1 - crypto.SHA256 -signature: - - crypto.FNV32a STRING +aliases: [/functions/crypto.fnv32a] --- This function calculates the 32 bit [FNV1a hash](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) of a given string according to the [specification](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-12): diff --git a/content/en/functions/hmac.md b/content/en/functions/crypto/HMAC.md similarity index 80% rename from content/en/functions/hmac.md rename to content/en/functions/crypto/HMAC.md index 4abd9f7b8..e58619b38 100644 --- a/content/en/functions/hmac.md +++ b/content/en/functions/crypto/HMAC.md @@ -1,21 +1,23 @@ --- -title: hmac +title: crypto.HMAC +linkTitle: hmac description: Returns a cryptographic hash that uses a key to sign a message. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: crypto -relatedFuncs: +function: + aliases: [hmac] + returnType: string + signatures: ['crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING]'] +relatedFunctions: - crypto.FNV32a - crypto.HMAC - crypto.MD5 - crypto.SHA1 - crypto.SHA256 -signature: - - crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING] - - hmac HASH_TYPE KEY MESSAGE [ENCODING] +aliases: [/functions/hmac] --- Set the `HASH_TYPE` argument to `md5`, `sha1`, `sha256`, or `sha512`. diff --git a/content/en/functions/md5.md b/content/en/functions/crypto/MD5.md similarity index 76% rename from content/en/functions/md5.md rename to content/en/functions/crypto/MD5.md index dc225bb8c..9415e015c 100644 --- a/content/en/functions/md5.md +++ b/content/en/functions/crypto/MD5.md @@ -1,21 +1,23 @@ --- -title: md5 +title: crypto.MD5 +linkTitle: md5 description: hashes the given input and returns its MD5 checksum. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: crypto -relatedFuncs: +function: + aliases: [md5] + returnType: string + signatures: [crypto.MD5 INPUT] +relatedFunctions: - crypto.FNV32a - crypto.HMAC - crypto.MD5 - crypto.SHA1 - crypto.SHA256 -signature: - - crypto.MD5 INPUT - - md5 INPUT +aliases: [/functions/md5] --- ```go-html-template diff --git a/content/en/functions/sha1.md b/content/en/functions/crypto/SHA1.md similarity index 64% rename from content/en/functions/sha1.md rename to content/en/functions/crypto/SHA1.md index 80dae32af..6269efe38 100644 --- a/content/en/functions/sha1.md +++ b/content/en/functions/crypto/SHA1.md @@ -1,22 +1,23 @@ --- -title: sha1 +title: crypto.SHA1 +linkTitle: sha1 description: Hashes the given input and returns its SHA1 checksum. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: crypto -relatedFuncs: +function: + aliases: [sha1] + returnType: string + signatures: [crypto.SHA1 INPUT] +relatedFunctions: - crypto.FNV32a - crypto.HMAC - crypto.MD5 - crypto.SHA1 - crypto.SHA256 -signature: - - crypto.SHA1 INPUT - - sha1 INPUT -aliases: [sha] +aliases: [/functions/sha,/functions/sha1] --- ```go-html-template diff --git a/content/en/functions/sha256.md b/content/en/functions/crypto/SHA256.md similarity index 67% rename from content/en/functions/sha256.md rename to content/en/functions/crypto/SHA256.md index dcd67cf78..3019432d2 100644 --- a/content/en/functions/sha256.md +++ b/content/en/functions/crypto/SHA256.md @@ -1,22 +1,23 @@ --- -title: sha256 +title: crypto.SHA256 +linkTitle: sha256 description: Hashes the given input and returns its SHA256 checksum. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: crypto -relatedFuncs: +function: + aliases: [sha256] + returnType: string + signatures: [crypto.SHA256 INPUT] +relatedFunctions: - crypto.FNV32a - crypto.HMAC - crypto.MD5 - crypto.SHA1 - crypto.SHA256 -signature: - - crypto.SHA256 INPUT - - sha256 INPUT -aliases: [sha] +aliases: [/functions/sha256] --- ```go-html-template diff --git a/content/en/functions/data/GetCSV.md b/content/en/functions/data/GetCSV.md new file mode 100644 index 000000000..e02c1588c --- /dev/null +++ b/content/en/functions/data/GetCSV.md @@ -0,0 +1,117 @@ +--- +title: data.GetCSV +linkTitle: getCSV +description: Returns an array of arrays from a local or remote CSV file, or an error if the file does not exist. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [getCSV] + returnType: '[]string' + signatures: [data.GetCSV SEPARATOR PATHPART...] +relatedFunctions: + - data.GetCSV + - data.GetJSON +toc: true +--- + +Given the following directory structure: + +```text +my-project/ +└── other-files/ + └── pets.csv +``` + +Access the data with either of the following: + +```go-html-template +{{ $data := getCSV "," "other-files/pets.csv" }} +{{ $data := getCSV "," "other-files/" "pets.csv" }} +``` + +Access remote data with either of the following: + +```go-html-template +{{ $data := getCSV "," "https://example.org/pets.csv" }} +{{ $data := getCSV "," "https://example.org/" "pets.csv" }} +``` + +The resulting data structure is an array of arrays: + +```json +[ + ["name","type","breed","age"], + ["Spot","dog","Collie","3"], + ["Felix","cat","Malicious","7"] +] +``` + +## Global resource alternative + +Consider using `resources.Get` with [`transform.Unmarshal`] when accessing a global resource. + +```text +my-project/ +└── assets/ + └── data/ + └── pets.csv +``` + +```go-html-template +{{ $data := "" }} +{{ $p := "data/pets.csv" }} +{{ with resources.Get $p }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} +{{ else }} + {{ errorf "Unable to get resource %q" $p }} +{{ end }} +``` + +## Page resource alternative + +Consider using `.Resources.Get` with [`transform.Unmarshal`] when accessing a page resource. + +```text +my-project/ +└── content/ + └── posts/ + └── my-pets/ + ├── index.md + └── pets.csv +``` + +```go-html-template +{{ $data := "" }} +{{ $p := "pets.csv" }} +{{ with .Resources.Get $p }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} +{{ else }} + {{ errorf "Unable to get resource %q" $p }} +{{ end }} +``` + +## Remote resource alternative + +Consider using `resources.GetRemote` with [`transform.Unmarshal`] for improved error handling when accessing a remote resource. + +```go-html-template +{{ $data := "" }} +{{ $u := "https://example.org/pets.csv" }} +{{ with resources.GetRemote $u }} + {{ with .Err }} + {{ errorf "%s" . }} + {{ else }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} + {{ end }} +{{ else }} + {{ errorf "Unable to get remote resource %q" $u }} +{{ end }} +``` + +[`transform.Unmarshal`]: /functions/transform/unmarshal diff --git a/content/en/functions/data/GetJSON.md b/content/en/functions/data/GetJSON.md new file mode 100644 index 000000000..37ee8e9a1 --- /dev/null +++ b/content/en/functions/data/GetJSON.md @@ -0,0 +1,124 @@ +--- +title: data.GetJSON +linkTitle: getJSON +description: Returns a JSON object from a local or remote JSON file, or an error if the file does not exist. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [getJSON] + returnType: any + signatures: [data.GetJSON PATHPART...] +relatedFunctions: + - data.GetCSV + - data.GetJSON +toc: true +--- + +Given the following directory structure: + +```text +my-project/ +└── other-files/ + └── books.json +``` + +Access the data with either of the following: + +```go-html-template +{{ $data := getCSV "," "other-files/books.json" }} +{{ $data := getCSV "," "other-files/" "books.json" }} +``` + +Access remote data with either of the following: + +```go-html-template +{{ $data := getCSV "," "https://example.org/books.json" }} +{{ $data := getCSV "," "https://example.org/" "books.json" }} +``` + +The resulting data structure is a JSON object: + +```json +[ + { + "author": "Victor Hugo", + "rating": 5, + "title": "Les Misérables" + }, + { + "author": "Victor Hugo", + "rating": 4, + "title": "The Hunchback of Notre Dame" + } +] +``` + +## Global resource alternative + +Consider using `resources.Get` with [`transform.Unmarshal`] when accessing a global resource. + +```text +my-project/ +└── assets/ + └── data/ + └── books.json +``` + +```go-html-template +{{ $data := "" }} +{{ $p := "data/books.json" }} +{{ with resources.Get $p }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} +{{ else }} + {{ errorf "Unable to get resource %q" $p }} +{{ end }} +``` + +## Page resource alternative + +Consider using `.Resources.Get` with [`transform.Unmarshal`] when accessing a page resource. + +```text +my-project/ +└── content/ + └── posts/ + └── reading-list/ + ├── books.json + └── index.md +``` + +```go-html-template +{{ $data := "" }} +{{ $p := "books.json" }} +{{ with .Resources.Get $p }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} +{{ else }} + {{ errorf "Unable to get resource %q" $p }} +{{ end }} +``` + +## Remote resource alternative + +Consider using `resources.GetRemote` with [`transform.Unmarshal`] for improved error handling when accessing a remote resource. + +```go-html-template +{{ $data := "" }} +{{ $u := "https://example.org/books.json" }} +{{ with resources.GetRemote $u }} + {{ with .Err }} + {{ errorf "%s" . }} + {{ else }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} + {{ end }} +{{ else }} + {{ errorf "Unable to get remote resource %q" $u }} +{{ end }} +``` + +[`transform.Unmarshal`]: /functions/transform/unmarshal diff --git a/content/en/functions/dateformat.md b/content/en/functions/dateformat.md deleted file mode 100644 index 226c903a7..000000000 --- a/content/en/functions/dateformat.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: time.Format -description: Converts a date/time to a localized string. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: time -relatedFuncs: - - time.AsTime - - time.Duration - - time.Format - - time.Now - - time.ParseDuration -signature: - - time.Format LAYOUT INPUT - - dateFormat LAYOUT INPUT ---- - -`time.Format` (alias `dateFormat`) converts either a `time.Time` object (e.g. `.Date`) or a timestamp string `INPUT` into the format specified by the `LAYOUT` string. - -```go-html-template -{{ time.Format "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015" -``` - -`time.Format` returns a localized string for the current language. - -The `LAYOUT` string can be either: - -* [Go’s Layout String](/functions/format/#gos-layout-string) to learn about how the `LAYOUT` string has to be formatted. There are also some useful examples. -* A custom Hugo layout identifier (see full list below) - -See the [`time` function](/functions/time/) to convert a timestamp string to a Go `time.Time` type value. - - -## Date/time formatting layouts - -Go's date layout strings can be hard to reason about, especially with multiple languages. You can alternatively use some predefined layout identifiers that will output localized dates or times: - -```go-html-template -{{ .Date | time.Format ":date_long" }} -``` - -The full list of custom layouts with examples for English: - -* `:date_full` => `Wednesday, June 6, 2018` -* `:date_long` => `June 6, 2018` -* `:date_medium` => `Jun 6, 2018` -* `:date_short` => `6/6/18` - -* `:time_full` => `2:09:37 am UTC` -* `:time_long` => `2:09:37 am UTC` -* `:time_medium` => `2:09:37 am` -* `:time_short` => `2:09 am` diff --git a/content/en/functions/debug/Dump.md b/content/en/functions/debug/Dump.md new file mode 100644 index 000000000..ff505a76b --- /dev/null +++ b/content/en/functions/debug/Dump.md @@ -0,0 +1,50 @@ +--- +title: debug.Dump +description: Returns an object dump as a string. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [debug.Dump VALUE] +relatedFunctions: [] +--- + +```go-html-template +{{ $data := "" }} +{{ $p := "data/books.json" }} +{{ with resources.Get $p }} + {{ $opts := dict "delimiter" "," }} + {{ $data = . | transform.Unmarshal $opts }} +{{ else }} + {{ errorf "Unable to get resource %q" $p }} +{{ end }} +``` + +```go-html-template +
{{ debug.Dump $data }}
+``` + +```text +[]interface {}{ + map[string]interface {}{ + "author": "Victor Hugo", + "rating": 5.0, + "title": "Les Misérables", + }, + map[string]interface {}{ + "author": "Victor Hugo", + "rating": 4.0, + "title": "The Hunchback of Notre Dame", + }, +} +``` + + + +{{% note %}} +Output from this function may change from one release to the next. Use for debugging only. +{{% /note %}} diff --git a/content/en/functions/base64Decode.md b/content/en/functions/encoding/Base64Decode.md similarity index 81% rename from content/en/functions/base64Decode.md rename to content/en/functions/encoding/Base64Decode.md index 05e950e1e..8bd554c83 100644 --- a/content/en/functions/base64Decode.md +++ b/content/en/functions/encoding/Base64Decode.md @@ -1,18 +1,20 @@ --- -title: base64Decode +title: encoding.Base64Decode +linkTitle: base64Decode description: Returns the base64 decoding of the given content. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: encoding -relatedFuncs: - - encoding.Base64Decode - - encoding.Base64Encode -signature: - - encoding.Base64Decode INPUT +function: + aliases: [base64Decode] + returnType: string + signatures: [encoding.Base64Decode INPUT] +signatures: + - - base64Decode INPUT +aliases: [/functions/base64Decode] --- ```go-html-template diff --git a/content/en/functions/base64Encode.md b/content/en/functions/encoding/Base64Encode.md similarity index 53% rename from content/en/functions/base64Encode.md rename to content/en/functions/encoding/Base64Encode.md index 3a0cbecff..d548aca8e 100644 --- a/content/en/functions/base64Encode.md +++ b/content/en/functions/encoding/Base64Encode.md @@ -1,19 +1,20 @@ --- -title: base64Encode +title: encoding.Base64Encode +linkTitle: base64Encode description: Returns the base64 decoding of the given content. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: encoding -relatedFuncs: +function: + aliases: [base64Encode] + returnType: string + signatures: [encoding.Base64Encode INPUT] +relatedFunctions: - encoding.Base64Decode - encoding.Base64Encode -signature: - - encoding.Base64Encode INPUT - - base64Encode INPUT -aliases: ['/functions/base64'] +aliases: [/functions/base64, /functions/base64Encode] --- ```go-html-template diff --git a/content/en/functions/jsonify.md b/content/en/functions/encoding/Jsonify.md similarity index 82% rename from content/en/functions/jsonify.md rename to content/en/functions/encoding/Jsonify.md index 6ce4556ec..0b9cb2e74 100644 --- a/content/en/functions/jsonify.md +++ b/content/en/functions/encoding/Jsonify.md @@ -1,21 +1,23 @@ --- -title: jsonify +title: encoding.Jsonify +linkTitle: jsonify description: Encodes a given object to JSON. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: encoding -relatedFuncs: +function: + aliases: [jsonify] + returnType: template.HTML + signatures: + - encoding.Jsonify INPUT + - encoding.Jsonify OPTIONS INPUT +relatedFunctions: - encoding.Jsonify - transform.Remarshal - transform.Unmarshal -signature: - - encoding.Jsonify INPUT - - encoding.Jsonify OPTIONS INPUT - - jsonify INPUT - - jsonify OPTIONS INPUT +aliases: [/functions/jsonify] --- To customize the printing of the JSON, pass a map of options as the first @@ -30,7 +32,7 @@ more copies of *indent* according to the indentation nesting. {{ dict "title" .Title "content" .Plain | jsonify (dict "prefix" " " "indent" " ") }} ``` -## Jsonify options +## Options indent ("") : Indentation to use. diff --git a/content/en/functions/errorf.md b/content/en/functions/fmt/Errorf.md similarity index 74% rename from content/en/functions/errorf.md rename to content/en/functions/fmt/Errorf.md index 5cb60554b..409c70c0a 100644 --- a/content/en/functions/errorf.md +++ b/content/en/functions/fmt/Errorf.md @@ -1,19 +1,21 @@ --- -title: errorf +title: fmt.Errorf +linkTitle: errorf description: Log an ERROR from a template. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [errorf] + returnType: string + signatures: ['fmt.Errorf FORMAT [INPUT]'] +relatedFunctions: - fmt.Errorf - fmt.Erroridf - fmt.Warnf -signature: - - fmt.Errorf FORMAT [INPUT] - - errorf FORMAT [INPUT] +aliases: [/functions/errorf] --- The documentation for [Go's fmt package] describes the structure and content of the format string. @@ -26,6 +28,6 @@ Like the [`printf`] function, the `errorf` function evaluates the format string Use the [`erroridf`] function to allow optional supression of specific errors. -[`erroridf`]: /functions/erroridf/ -[`printf`]: /functions/printf/ +[`erroridf`]: /functions/fmt/erroridf +[`printf`]: /functions/fmt/printf [Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/erroridf.md b/content/en/functions/fmt/Erroridf.md similarity index 83% rename from content/en/functions/erroridf.md rename to content/en/functions/fmt/Erroridf.md index fd6118694..2271be2ac 100644 --- a/content/en/functions/erroridf.md +++ b/content/en/functions/fmt/Erroridf.md @@ -1,19 +1,21 @@ --- -title: erroridf +title: fmt.Erroridf +linkTitle: erroridf description: Log a suppressable ERROR from a template. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [erroridf] + returnType: string + signatures: ['fmt.Erroridf ID FORMAT [INPUT]'] +relatedFunctions: - fmt.Errorf - fmt.Erroridf - fmt.Warnf -signature: - - fmt.Erroridf ID FORMAT [INPUT] - - erroridf ID FORMAT [INPUT] +aliases: [/functions/erroridf] --- The documentation for [Go's fmt package] describes the structure and content of the format string. @@ -42,5 +44,5 @@ To suppress this message: ignoreErrors = ["error-42"] {{< /code-toggle >}} -[`errorf`]: /functions/errorf/ +[`errorf`]: /functions/fmt/errorf [Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/print.md b/content/en/functions/fmt/Print.md similarity index 69% rename from content/en/functions/print.md rename to content/en/functions/fmt/Print.md index 19098057b..f9ff885f8 100644 --- a/content/en/functions/print.md +++ b/content/en/functions/fmt/Print.md @@ -1,19 +1,21 @@ --- -title: print +title: fmt.Print +linkTitle: print description: Prints the default representation of the given arguments using the standard `fmt.Print` function. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [print] + returnType: string + signatures: [fmt.Print INPUT] +relatedFunctions: - fmt.Print - fmt.Printf - fmt.Println -signature: - - fmt.Print INPUT - - print INPUT +aliases: [/functions/print] --- ```go-html-template diff --git a/content/en/functions/printf.md b/content/en/functions/fmt/Printf.md similarity index 82% rename from content/en/functions/printf.md rename to content/en/functions/fmt/Printf.md index 1286acb1c..06b7222e9 100644 --- a/content/en/functions/printf.md +++ b/content/en/functions/fmt/Printf.md @@ -1,19 +1,21 @@ --- -title: printf +title: fmt.Printf +linkTitle: printf description: Formats a string using the standard `fmt.Sprintf` function. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [printf] + returnType: string + signatures: ['fmt.Printf FORMAT [INPUT]'] +relatedFunctions: - fmt.Print - fmt.Printf - fmt.Println -signature: - - fmt.Printf FORMAT [INPUT] - - printf FORMAT [INPUT] +aliases: [/functions/printf] --- The documentation for [Go's fmt package] describes the structure and content of the format string. diff --git a/content/en/functions/println.md b/content/en/functions/fmt/Println.md similarity index 64% rename from content/en/functions/println.md rename to content/en/functions/fmt/Println.md index 5eca89a8c..358b5f8ac 100644 --- a/content/en/functions/println.md +++ b/content/en/functions/fmt/Println.md @@ -1,19 +1,21 @@ --- -title: println +title: fmt.Println +linkTitle: println description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a linebreak. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [println] + returnType: string + signatures: [fmt.Println INPUT] +relatedFunctions: - fmt.Print - fmt.Printf - fmt.Println -signature: - - fmt.Println INPUT - - println INPUT +aliases: [/functions/println] --- ```go-html-template diff --git a/content/en/functions/warnf.md b/content/en/functions/fmt/Warnf.md similarity index 74% rename from content/en/functions/warnf.md rename to content/en/functions/fmt/Warnf.md index d076528f3..be579a216 100644 --- a/content/en/functions/warnf.md +++ b/content/en/functions/fmt/Warnf.md @@ -1,19 +1,21 @@ --- -title: warnf +title: fmt.Warnf +linkTitle: warnf description: Log a WARNING from a template. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: fmt -relatedFuncs: +function: + aliases: [warnf] + returnType: string + signatures: ['fmt.Warnf FORMAT [INPUT]'] +relatedFunctions: - fmt.Errorf - fmt.Erroridf - fmt.Warnf -signature: - - fmt.Warnf FORMAT [INPUT] - - warnf FORMAT [INPUT] +aliases: [/functions/warnf] --- The documentation for [Go's fmt package] describes the structure and content of the format string. @@ -24,5 +26,5 @@ Like the [`printf`] function, the `warnf` function evaluates the format string. {{ warnf "Copyright notice missing from site configuration" }} ``` -[`printf`]: /functions/printf/ +[`printf`]: /functions/fmt/printf [Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/format.md b/content/en/functions/format.md deleted file mode 100644 index 14410e8dc..000000000 --- a/content/en/functions/format.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: .Format -description: Formats built-in Hugo dates---`.Date`, `.PublishDate`, and `.Lastmod`---according to Go's layout string. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: -relatedFuncs: [] -signature: - - .Format FORMAT -toc: true ---- - -`.Format` will format date values defined in your front matter and can be used as a property on the following [page variables][pagevars]: - -* `.PublishDate` -* `.Date` -* `.Lastmod` - -Assuming a key-value of `date: 2017-03-03` in a content file's front matter, your can run the date through `.Format` followed by a layout string for your desired output at build time: - -```go-html-template -{{ .PublishDate.Format "January 2, 2006" }} => March 3, 2017 -``` - -For formatting *any* string representations of dates defined in your front matter, see the [`dateFormat` function][dateFormat], which will still leverage the Go layout string explained below but uses a slightly different syntax. - -## Go's layout string - -Hugo templates [format your dates][time] via layout strings that point to a specific reference time: - -``` -Mon Jan 2 15:04:05 MST 2006 -``` - -While this may seem arbitrary, the numerical value of `MST` is `07`, thus making the layout string a sequence of numbers. - -Here is a visual explanation [taken directly from the Go docs][gdex]: - -``` - Jan 2 15:04:05 2006 MST -=> 1 2 3 4 5 6 -7 -``` - -### Hugo date and time templating reference - -The following examples show the layout string followed by the rendered output. - -The examples were rendered and tested in [CST] and all point to the same field in a content file's front matter: - -``` -date: 2017-03-03T14:15:59-06:00 -``` - -`.Date` (i.e. called via [page variable][pagevars]) -: **Returns**: `2017-03-03 14:15:59 -0600 CST` - -`"Monday, January 2, 2006"` -: **Returns**: `Friday, March 3, 2017` - -`"Mon Jan 2 2006"` -: **Returns**: `Fri Mar 3 2017` - -`"January 2006"` -: **Returns**: `March 2017` - -`"2006-01-02"` -: **Returns**: `2017-03-03` - -`"Monday"` -: **Returns**: `Friday` - -`"02 Jan 06 15:04 MST"` (RFC822) -: **Returns**: `03 Mar 17 14:15 CST` - -`"02 Jan 06 15:04 -0700"` (RFC822Z) -: **Returns**: `03 Mar 17 14:15 -0600` - -`"Mon, 02 Jan 2006 15:04:05 MST"` (RFC1123) -: **Returns**: `Fri, 03 Mar 2017 14:15:59 CST` - -`"Mon, 02 Jan 2006 15:04:05 -0700"` (RFC1123Z) -: **Returns**: `Fri, 03 Mar 2017 14:15:59 -0600` - -More examples can be found in Go's [documentation for the time package][timeconst]. - -### Cardinal s - -Spelled-out cardinal numbers (e.g. "one", "two", and "three") are not currently supported. - -Use the [`humanize`](/functions/humanize) function to render the day of the month as an ordinal number: - -```go-html-template -{{ humanize .Date.Day }} of {{ .Date.Format "January 2006" }} -``` - -This will output: - -``` -5th of March 2017 -``` - - -### Use `.Local` and `.UTC` - -In conjunction with the [`dateFormat` function][dateFormat], you can also convert your dates to `UTC` or to local timezones: - -`{{ dateFormat "02 Jan 06 15:04 MST" .Date.UTC }}` -: **Returns**: `03 Mar 17 20:15 UTC` - -`{{ dateFormat "02 Jan 06 15:04 MST" .Date.Local }}` -: **Returns**: `03 Mar 17 14:15 CST` - -[CST]: https://en.wikipedia.org/wiki/Central_Time_Zone -[dateFormat]: /functions/dateformat/ -[gdex]: https://golang.org/pkg/time/#example_Time_Format -[pagevars]: /variables/page/ -[time]: https://golang.org/pkg/time/ -[timeconst]: https://golang.org/pkg/time/#ANSIC diff --git a/content/en/functions/len.md b/content/en/functions/go-template/len.md similarity index 80% rename from content/en/functions/len.md rename to content/en/functions/go-template/len.md index 6be348104..b8be621e8 100644 --- a/content/en/functions/len.md +++ b/content/en/functions/go-template/len.md @@ -2,20 +2,25 @@ title: len description: Returns the length of a string, slice, map, or collection. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: text/template -relatedFuncs: +function: + aliases: [] + returnType: int + signatures: [len INPUT] +relatedFunctions: - len - strings.Count - strings.CountRunes - strings.CountWords - strings.RuneCount -signature: ["len INPUT"] +aliases: [/functions/len] --- +{{% readfile file="/functions/_common/go-template-functions.md" %}} + With a string: ```go-html-template diff --git a/content/en/functions/go-template/range.md b/content/en/functions/go-template/range.md new file mode 100644 index 000000000..cf01633b4 --- /dev/null +++ b/content/en/functions/go-template/range.md @@ -0,0 +1,159 @@ +--- +title: range +description: Iterates over slices, maps, and page collections. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: + signatures: [range COLLECTION] +relatedFunctions: + - with + - range +aliases: [/functions/range] +toc: true +--- + +{{% readfile file="/functions/_common/go-template-functions.md" %}} + +## Slices + +Template: + +```go-html-template +{{ $s := slice "foo" "bar" "baz" }} +{{ range $s }} +

{{ . }}

+{{ end }} +``` + +Result: + +```html +

foo

+

bar

+

baz

+``` + +Template: + +```go-html-template +{{ $s := slice "foo" "bar" "baz" }} +{{ range $v := $s }} +

{{ $v }}

+{{ end }} +``` + +Result: + +```html +

foo

+

bar

+

baz

+``` + +Template: + +```go-html-template +{{ $s := slice "foo" "bar" "baz" }} +{{ range $k, $v := $s }} +

{{ $k }}: {{ $v }}

+{{ end }} +``` + +Result: + +```html +

0: foo

+

1: bar

+

2: baz

+``` + +## Maps + +Template: + +```go-html-template +{{ $m := slice + (dict "name" "John" "age" 30) + (dict "name" "Will" "age" 28) + (dict "name" "Joey" "age" 24) +}} +{{ range $m }} +

{{ .name }} is {{ .age }}

+{{ end }} +``` + +Result: + +```html +

John is 30

+

Will is 28

+

Joey is 24

+``` + +## Page collections + +Template: + +```go-html-template +{{ range where site.RegularPages "Type" "articles" }} +

{{ .LinkTitle }}

+{{ end }} +``` + +Result: + +```html +

Article 3

+

Article 2

+

Article 1

+``` + +## Break + +Use the `break` statement to stop the innermost iteration and bypass all remaining iterations. + +Template: + +```go-html-template +{{ $s := slice "foo" "bar" "baz" }} +{{ range $s }} + {{ if eq . "bar" }} + {{ break }} + {{ end }} +

{{ . }}

+{{ end }} +``` + +Result: + +```html +

foo

+``` + +## Continue + +Use the `continue` statement to stop the innermost iteration and continue to the next iteration. + +Template: + +```go-html-template +{{ $s := slice "foo" "bar" "baz" }} +{{ range $s }} + {{ if eq . "bar" }} + {{ continue }} + {{ end }} +

{{ . }}

+{{ end }} +``` + +Result: + +```html +

foo

+

baz

+``` diff --git a/content/en/functions/urlquery.md b/content/en/functions/go-template/urlquery.md similarity index 71% rename from content/en/functions/urlquery.md rename to content/en/functions/go-template/urlquery.md index 92d17378f..cbbfdfa7d 100644 --- a/content/en/functions/urlquery.md +++ b/content/en/functions/go-template/urlquery.md @@ -2,18 +2,22 @@ title: urlquery description: Returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: text/template -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: ['urlquery INPUT [INPUT]...'] +relatedFunctions: - collections.Querify - urlquery -signature: - - urlquery INPUT [INPUT]... +aliases: [/functions/urlquery] --- +{{% readfile file="/functions/_common/go-template-functions.md" %}} + This template code: ```go-html-template diff --git a/content/en/functions/with.md b/content/en/functions/go-template/with.md similarity index 82% rename from content/en/functions/with.md rename to content/en/functions/go-template/with.md index 07426f281..06ca38150 100644 --- a/content/en/functions/with.md +++ b/content/en/functions/go-template/with.md @@ -2,23 +2,27 @@ title: with description: Rebinds the context (`.`) within its scope and skips the block if the variable is absent or empty. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: text/template -relatedFuncs: +function: + aliases: [] + returnType: any + signatures: [with PIPELINE] +relatedFunctions: - with - range -signature: - - with INPUT +aliases: [/functions/with] --- +{{% readfile file="/functions/_common/go-template-functions.md" %}} + An alternative way of writing an `if` statement and then referencing the same value is to use `with` instead. `with` rebinds the context (`.`) within its scope and skips the block if the variable is absent, unset or empty. The set of *empty* values is defined by [the Go templates package](https://golang.org/pkg/text/template/). Empty values include `false`, the number zero, and the empty string. -If you want to render a block if an index or key is present in a slice, array, channel or map, regardless of whether the value is empty, you should use [`isset`](/functions/isset) instead. +If you want to render a block if an index or key is present in a slice, array, channel or map, regardless of whether the value is empty, you should use [`isset`](/functions/collections/isset) instead. The following example checks for a [user-defined site variable](/variables/site/) called `twitteruser`. If the key-value is not set, the following will render nothing: diff --git a/content/en/functions/hasmenucurrent.md b/content/en/functions/hasmenucurrent.md deleted file mode 100644 index 822a3d2ee..000000000 --- a/content/en/functions/hasmenucurrent.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: .HasMenuCurrent -description: -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: -relatedFuncs: - - .HasMenuCurrent - - .IsMenuCurrent -signature: - - PAGE.HasMenuCurrent MENU MENUENTRY ---- - -`.HasMenuCurrent` is a method in `Page` object returning a _boolean_ value. It -returns `true` if the PAGE is the same object as the `.Page` in one of the -**children menu entries** under MENUENTRY in a given MENU. - -If MENUENTRY's `.Page` is a [section](/content-management/sections/) then, from Hugo `0.86.0`, this method also returns true for any descendant of that section.. - -You can find its example use in [menu templates](/templates/menu-templates/). diff --git a/content/en/functions/hugo.md b/content/en/functions/hugo/index.md similarity index 94% rename from content/en/functions/hugo.md rename to content/en/functions/hugo/index.md index a60a016f7..208ea39b5 100644 --- a/content/en/functions/hugo.md +++ b/content/en/functions/hugo/index.md @@ -1,15 +1,20 @@ --- title: hugo -description: The `hugo` function provides easy access to Hugo-related data. -keywords: [] +description: Provides global access to Hugo-related data. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: global -relatedFuncs: [] -signature: [hugo] +function: + aliases: [] + returnType: + signatures: [hugo] +relatedFunctions: + - hugo + - page + - site +aliases: [/functions/hugo] --- `hugo` returns an instance that contains the following functions: diff --git a/content/en/functions/images/index.md b/content/en/functions/images/index.md index 779e2cc96..a71c2b61c 100644 --- a/content/en/functions/images/index.md +++ b/content/en/functions/images/index.md @@ -2,6 +2,7 @@ title: Image filters description: The images namespace provides a list of filters and other image related functions. categories: [functions] +keywords: [] aliases: [/functions/imageconfig/] menu: docs: @@ -270,4 +271,4 @@ favicon.ico: {{ .Width }} x {{ .Height }} {{ end }} ``` -[`Process`]: #process \ No newline at end of file +[`Process`]: #process diff --git a/content/en/functions/in.md b/content/en/functions/in.md deleted file mode 100644 index 6fdabc07f..000000000 --- a/content/en/functions/in.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: in -description: Checks if an element is in an array or slice---or a substring in a string---and returns a boolean. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: collections -relatedFuncs: - - strings.Contains - - strings.ContainsAny - - strings.ContainsNonSpace - - strings.HasPrefix - - strings.HasSuffix -signature: - - collections.In SET ITEM - - in SET ITEM ---- - -The elements supported are strings, integers and floats, although only float64 will match as expected. - -In addition, `in` can also check if a substring exists in a string. - -```go-html-template -{{ if in .Params.tags "Git" }}Follow me on GitHub!{{ end }} -``` - - -```go-html-template -{{ if in "this string contains a substring" "substring" }}Substring found!{{ end }} -``` diff --git a/content/en/functions/humanize.md b/content/en/functions/inflect/Humanize.md similarity index 75% rename from content/en/functions/humanize.md rename to content/en/functions/inflect/Humanize.md index 7611a6715..74d24f310 100644 --- a/content/en/functions/humanize.md +++ b/content/en/functions/inflect/Humanize.md @@ -1,19 +1,21 @@ --- -title: humanize +title: inflect.Humanize +linkTitle: humanize description: Returns the humanized version of an argument with the first letter capitalized. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: inflect -relatedFuncs: +function: + aliases: [humanize] + returnType: string + signatures: [inflect.Humanize INPUT] +relatedFunctions: - inflect.Humanize - inflect.Pluralize - inflect.Singularize -signature: - - inflect.Humanize INPUT - - humanize INPUT +aliases: [/functions/humanize] --- If the input is either an int64 value or the string representation of an integer, humanize returns the number with the proper ordinal appended. diff --git a/content/en/functions/pluralize.md b/content/en/functions/inflect/Pluralize.md similarity index 61% rename from content/en/functions/pluralize.md rename to content/en/functions/inflect/Pluralize.md index 928a6683f..5bb444114 100644 --- a/content/en/functions/pluralize.md +++ b/content/en/functions/inflect/Pluralize.md @@ -1,19 +1,21 @@ --- -title: pluralize +title: inflect.Pluralize +linkTitle: pluralize description: Pluralizes the given word according to a set of common English pluralization rules categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: inflect -relatedFuncs: +function: + aliases: [pluralize] + returnType: string + signatures: [inflect.Pluralize INPUT] +relatedFunctions: - inflect.Humanize - inflect.Pluralize - inflect.Singularize -signature: - - inflect.Pluralize INPUT - - pluralize INPUT +aliases: [/functions/pluralize] --- ```go-html-template diff --git a/content/en/functions/singularize.md b/content/en/functions/inflect/Singularize.md similarity index 56% rename from content/en/functions/singularize.md rename to content/en/functions/inflect/Singularize.md index f5b85d304..5aba4e4ee 100644 --- a/content/en/functions/singularize.md +++ b/content/en/functions/inflect/Singularize.md @@ -1,21 +1,25 @@ --- -title: singularize +title: inflect.Singularize +linkTitle: singularize description: Converts a word according to a set of common English singularization rules. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: inflect -relatedFuncs: +function: + aliases: [singularize] + returnType: string + signatures: [inflect.Singularize INPUT] +relatedFunctions: - inflect.Humanize - inflect.Pluralize - inflect.Singularize -signature: - - inflect.Singularize INPUT - - singularize INPUT +aliases: [/functions/singularize] --- -`{{ "cats" | singularize }}` → "cat" +```go-html-template +{{ "cats" | singularize }} → "cat" +``` See also the `.Data.Singular` [taxonomy variable](/variables/taxonomy/) for singularizing taxonomy names. diff --git a/content/en/functions/ismenucurrent.md b/content/en/functions/ismenucurrent.md deleted file mode 100644 index 4ec3daca7..000000000 --- a/content/en/functions/ismenucurrent.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: .IsMenuCurrent -description: -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: -relatedFuncs: - - .HasMenuCurrent - - .IsMenuCurrent -signature: - - PAGE.IsMenuCurrent MENU MENUENTRY ---- - -`.IsMenuCurrent` is a method in `Page` object returning a _boolean_ value. It -returns `true` if the PAGE is the same object as the `.Page` in MENUENTRY in a -given MENU. - -You can find its example use in [menu templates](/templates/menu-templates/). diff --git a/content/en/functions/lang.md b/content/en/functions/lang.md deleted file mode 100644 index d114d8558..000000000 --- a/content/en/functions/lang.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: lang -package: lang -description: "Functions in the language namespace." -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -relatedFuncs: [] -signature: [] -aliases: ['/functions/numfmt/'] -type: 'template-func' ---- diff --git a/content/en/functions/lang/FormatAccounting.md b/content/en/functions/lang/FormatAccounting.md new file mode 100644 index 000000000..974dc4a1a --- /dev/null +++ b/content/en/functions/lang/FormatAccounting.md @@ -0,0 +1,27 @@ +--- +title: lang.FormatAccounting +description: Returns a currency representation of a number for the given currency and precision for the current language in accounting notation. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [lang.FormatAccounting PRECISION CURRENCY NUMBER] +relatedFunctions: + - lang.FormatAccounting + - lang.FormatCurrency + - lang.FormatNumber + - lang.FormatNumberCustom + - lang.FormatPercent +--- + +```go-html-template +{{ 512.5032 | lang.FormatAccounting 2 "NOK" }} → NOK512.50 +``` + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} diff --git a/content/en/functions/lang/FormatCurrency.md b/content/en/functions/lang/FormatCurrency.md new file mode 100644 index 000000000..b29a807fe --- /dev/null +++ b/content/en/functions/lang/FormatCurrency.md @@ -0,0 +1,27 @@ +--- +title: lang.FormatCurrency +description: Returns a currency representation of a number for the given currency and precision for the current language. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [lang.FormatAccounting PRECISION CURRENCY NUMBER] +relatedFunctions: + - lang.FormatAccounting + - lang.FormatCurrency + - lang.FormatNumber + - lang.FormatNumberCustom + - lang.FormatPercent +--- + +```go-html-template +{{ 512.5032 | lang.FormatCurrency 2 "USD" }} → $512.50 +``` + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} diff --git a/content/en/functions/lang/FormatNumber.md b/content/en/functions/lang/FormatNumber.md new file mode 100644 index 000000000..dd878fdef --- /dev/null +++ b/content/en/functions/lang/FormatNumber.md @@ -0,0 +1,27 @@ +--- +title: lang.FormatNumber +description: Returns a numeric representation of a number with the given precision for the current language. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [lang.FormatNumber PRECISION NUMBER] +relatedFunctions: + - lang.FormatAccounting + - lang.FormatCurrency + - lang.FormatNumber + - lang.FormatNumberCustom + - lang.FormatPercent +--- + +```go-html-template +{{ 512.5032 | lang.FormatNumber 2 }} → 512.50 +``` + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} diff --git a/content/en/functions/lang/FormatNumberCustom.md b/content/en/functions/lang/FormatNumberCustom.md new file mode 100644 index 000000000..97b022567 --- /dev/null +++ b/content/en/functions/lang/FormatNumberCustom.md @@ -0,0 +1,41 @@ +--- +title: lang.FormatNumberCustom +description: Returns a numeric representation of a number with the given precision using negative, decimal, and grouping options. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: ['lang.FormatNumberCustom PRECISION NUMBER [OPTIONS...]'] +relatedFunctions: + - lang.FormatAccounting + - lang.FormatCurrency + - lang.FormatNumber + - lang.FormatNumberCustom + - lang.FormatPercent +aliases: ['/functions/numfmt/'] +--- + +This function formats a number with the given precision. The first options parameter is a space-delimited string of characters to represent negativity, the decimal point, and grouping. The default value is `- . ,`. The second options parameter defines an alternate delimiting character. + +Note that numbers are rounded up at 5 or greater. So, with precision set to 0, 1.5 becomes 2, and 1.4 becomes 1. + +For a simpler function that adapts to the current language, see [`lang.FormatNumber`]. + + +```go-html-template +{{ lang.FormatNumberCustom 2 12345.6789 }} → 12,345.68 +{{ lang.FormatNumberCustom 2 12345.6789 "- , ." }} → 12.345,68 +{{ lang.FormatNumberCustom 6 -12345.6789 "- ." }} → -12345.678900 +{{ lang.FormatNumberCustom 0 -12345.6789 "- . ," }} → -12,346 +{{ lang.FormatNumberCustom 0 -12345.6789 "-|.| " "|" }} → -12 346 +``` + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} + +[`lang.FormatNumber`]: /functions/lang/formatnumber diff --git a/content/en/functions/lang/FormatPercent.md b/content/en/functions/lang/FormatPercent.md new file mode 100644 index 000000000..dd2042490 --- /dev/null +++ b/content/en/functions/lang/FormatPercent.md @@ -0,0 +1,27 @@ +--- +title: lang.FormatPercent +description: Returns a percentage representation of a number with the given precision for the current language. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [lang.FormatPercent PRECISION NUMBER] +relatedFunctions: + - lang.FormatAccounting + - lang.FormatCurrency + - lang.FormatNumber + - lang.FormatNumberCustom + - lang.FormatPercent +--- + +```go-html-template +{{ 512.5032 | lang.FormatPercent 2 }} → 512.50% +``` + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} diff --git a/content/en/functions/lang.Merge.md b/content/en/functions/lang/Merge.md similarity index 83% rename from content/en/functions/lang.Merge.md rename to content/en/functions/lang/Merge.md index ebd771c65..b3d21cd7a 100644 --- a/content/en/functions/lang.Merge.md +++ b/content/en/functions/lang/Merge.md @@ -2,14 +2,16 @@ title: lang.Merge description: Merge missing translations from other languages. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: lang -relatedFuncs: [] -signature: - - lang.Merge FROM TO +function: + aliases: [] + returnType: any + signatures: [lang.Merge FROM TO] +relatedFunctions: [] +aliases: [/functions/lang.merge] --- As an example: diff --git a/content/en/functions/i18n.md b/content/en/functions/lang/Translate.md similarity index 71% rename from content/en/functions/i18n.md rename to content/en/functions/lang/Translate.md index bdea419a5..718d8cfb2 100644 --- a/content/en/functions/i18n.md +++ b/content/en/functions/lang/Translate.md @@ -1,17 +1,18 @@ --- -title: i18n +title: lang.Translate +linkTitle: i18n description: Translates a string using the translation tables in the i18n directory. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: lang -relatedFuncs: [] -signature: - - lang.Translate KEY [CONTEXT] - - i18n KEY [CONTEXT] - - T KEY [CONTEXT] +function: + aliases: [i18n,T] + returnType: string + signatures: ['lang.Translate KEY [CONTEXT]'] +relatedFunctions: [] +aliases: [/functions/i18n] --- Let's say your multilingual site supports two languages, English and Polish. Create a translation table for each language in the `i18n` directory. @@ -76,35 +77,35 @@ The examples below use the `T` alias for brevity. When viewing the English language site: ```go-html-template -{{ T "privacy" }} --> privacy -{{ T "security" }} --> security +{{ T "privacy" }} → privacy +{{ T "security" }} → security -{{ T "day" 0 }} --> days -{{ T "day" 1 }} --> day -{{ T "day" 2 }} --> days -{{ T "day" 5 }} --> days +{{ T "day" 0 }} → days +{{ T "day" 1 }} → day +{{ T "day" 2 }} → days +{{ T "day" 5 }} → days -{{ T "day_with_count" 0 }} --> 0 days -{{ T "day_with_count" 1 }} --> 1 day -{{ T "day_with_count" 2 }} --> 2 days -{{ T "day_with_count" 5 }} --> 5 days +{{ T "day_with_count" 0 }} → 0 days +{{ T "day_with_count" 1 }} → 1 day +{{ T "day_with_count" 2 }} → 2 days +{{ T "day_with_count" 5 }} → 5 days ```` When viewing the Polish language site: ```go-html-template -{{ T "privacy" }} --> prywatność -{{ T "security" }} --> bezpieczeństwo +{{ T "privacy" }} → prywatność +{{ T "security" }} → bezpieczeństwo -{{ T "day" 0 }} --> miesięcy -{{ T "day" 1 }} --> miesiąc -{{ T "day" 2 }} --> miesiące -{{ T "day" 5 }} --> miesięcy +{{ T "day" 0 }} → miesięcy +{{ T "day" 1 }} → miesiąc +{{ T "day" 2 }} → miesiące +{{ T "day" 5 }} → miesięcy -{{ T "day_with_count" 0 }} --> 0 miesięcy -{{ T "day_with_count" 1 }} --> 1 miesiąc -{{ T "day_with_count" 2 }} --> 2 miesiące -{{ T "day_with_count" 5 }} --> 5 miesięcy +{{ T "day_with_count" 0 }} → 0 miesięcy +{{ T "day_with_count" 1 }} → 1 miesiąc +{{ T "day_with_count" 2 }} → 2 miesiące +{{ T "day_with_count" 5 }} → 5 miesięcy ``` In the pluralization examples above, we passed an integer in context (the second argument). You can also pass a map in context, creating a `count` key to control pluralization. diff --git a/content/en/functions/math.md b/content/en/functions/math/index.md similarity index 97% rename from content/en/functions/math.md rename to content/en/functions/math/index.md index b9d7bbeab..fd4d10a31 100644 --- a/content/en/functions/math.md +++ b/content/en/functions/math/index.md @@ -2,12 +2,16 @@ title: math description: Hugo provides mathematical operators in templates. categories: [functions] +keywords: [] + menu: docs: parent: functions -keywords: [] -relatedFuncs: [] -signature: [] +function: + aliases: [] + returnType: + signatures: [] +relatedFunctions: [] --- | Function | Description | Example | diff --git a/content/en/functions/fileExists.md b/content/en/functions/os/FileExists.md similarity index 79% rename from content/en/functions/fileExists.md rename to content/en/functions/os/FileExists.md index 2f658a83d..52cfe32c8 100644 --- a/content/en/functions/fileExists.md +++ b/content/en/functions/os/FileExists.md @@ -1,20 +1,23 @@ --- -title: fileExists -description: Checks for file or directory existence. +title: os.FileExists +linkTitle: fileExists +description: Reports whether the file or directory exists. categories: [functions] +keywords: [] menu: docs: parent: functions -namespace: os -relatedFuncs: +function: + aliases: [fileExists] + returnType: bool + signatures: [os.FileExists PATH] +relatedFunctions: - os.FileExists - os.Getenv - os.ReadDir - os.ReadFile - os.Stat -signature: - - os.FileExists PATH - - fileExists PATH +aliases: [/functions/fileexists] --- The `os.FileExists` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional. diff --git a/content/en/functions/getenv.md b/content/en/functions/os/Getenv.md similarity index 84% rename from content/en/functions/getenv.md rename to content/en/functions/os/Getenv.md index b3422dc72..16f73f5aa 100644 --- a/content/en/functions/getenv.md +++ b/content/en/functions/os/Getenv.md @@ -1,21 +1,23 @@ --- -title: getenv +title: os.Getenv +linkTitle: getenv description: Returns the value of an environment variable, or an empty string if the environment variable is not set. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: os -relatedFuncs: +function: + aliases: [getenv] + returnType: string + signatures: [os.Getenv VARIABLE] +relatedFunctions: - os.FileExists - os.Getenv - os.ReadDir - os.ReadFile - os.Stat -signature: - - os.Getenv VARIABLE - - getenv VARIABLE +aliases: [/functions/getenv] --- Examples: diff --git a/content/en/functions/readdir.md b/content/en/functions/os/ReadDir.md similarity index 81% rename from content/en/functions/readdir.md rename to content/en/functions/os/ReadDir.md index 9de88bf67..d0ed87bdf 100644 --- a/content/en/functions/readdir.md +++ b/content/en/functions/os/ReadDir.md @@ -1,21 +1,23 @@ --- -title: readDir +title: os.ReadDir +linkTitle: readDir description: Returns an array of FileInfo structures sorted by file name, one element for each directory entry. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: os -relatedFuncs: +function: + aliases: [readDir] + returnType: FileInfo + signatures: [os.ReadDir PATH] +relatedFunctions: - os.FileExists - os.Getenv - os.ReadDir - os.ReadFile - os.Stat -signature: - - os.ReadDir PATH - - readDir PATH +aliases: [/functions/readdir] --- The `os.ReadDir` function resolves the path relative to the root of your project directory. A leading path separator (`/`) is optional. @@ -42,9 +44,9 @@ This template code: Produces: ```html -about.md --> false -contact.md --> false -news --> true +about.md → false +contact.md → false +news → true ``` Note that `os.ReadDir` is not recursive. diff --git a/content/en/functions/readfile.md b/content/en/functions/os/ReadFile.md similarity index 83% rename from content/en/functions/readfile.md rename to content/en/functions/os/ReadFile.md index 79b45a370..30f2b3056 100644 --- a/content/en/functions/readfile.md +++ b/content/en/functions/os/ReadFile.md @@ -1,21 +1,23 @@ --- -title: readFile +title: os.ReadFile +linkTitle: readFile description: Returns the contents of a file. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: os -relatedFuncs: +function: + aliases: [readFile] + returnType: string + signatures: [os.ReadFile PATH] +relatedFunctions: - os.FileExists - os.Getenv - os.ReadDir - os.ReadFile - os.Stat -signature: - - os.ReadFile PATH - - readFile PATH +aliases: [/functions/readfile] --- The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional. diff --git a/content/en/functions/os.Stat.md b/content/en/functions/os/Stat.md similarity index 88% rename from content/en/functions/os.Stat.md rename to content/en/functions/os/Stat.md index c612f9f19..dfef3c815 100644 --- a/content/en/functions/os.Stat.md +++ b/content/en/functions/os/Stat.md @@ -2,19 +2,21 @@ title: os.Stat description: Returns a FileInfo structure describing a file or directory. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: os -relatedFuncs: +function: + aliases: [] + returnType: FileInfo + signatures: [os.Stat PATH] +relatedFunctions: - os.FileExists - os.Getenv - os.ReadDir - os.ReadFile - os.Stat -signature: - - os.Stat PATH +aliases: [/functions/os.stat] --- The `os.Stat` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional. diff --git a/content/en/functions/page.md b/content/en/functions/page/index.md similarity index 96% rename from content/en/functions/page.md rename to content/en/functions/page/index.md index c2eb35758..01f014078 100644 --- a/content/en/functions/page.md +++ b/content/en/functions/page/index.md @@ -2,15 +2,19 @@ title: page description: Provides global access to the .Page object. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: global -relatedFuncs: +function: + aliases: [] + returnType: + signatures: [page] +relatedFunctions: + - hugo - page - site -signature: [page] +aliases: [/functions/page] --- At the top level of a template that receives the `Page` object in context, these are equivalent: diff --git a/content/en/functions/partial.md b/content/en/functions/partials/Include.md similarity index 88% rename from content/en/functions/partial.md rename to content/en/functions/partials/Include.md index 447f6d623..ea9dfb31a 100644 --- a/content/en/functions/partial.md +++ b/content/en/functions/partials/Include.md @@ -1,18 +1,20 @@ --- -title: partial +title: partials.Include +linkTitle: partial description: Executes the named partial template. If the partial contains a return statement, returns that value, else returns the rendered output. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: partials -relatedFuncs: +function: + aliases: [partial] + returnType: any + signatures: ['partials.Include LAYOUT [CONTEXT]'] +relatedFunctions: - partials.Include - partials.IncludeCached -signature: - - partials.Include LAYOUT [CONTEXT] - - partial LAYOUT [CONTEXT] +aliases: [/functions/partial] --- In this example we have three partial templates: diff --git a/content/en/functions/partialCached.md b/content/en/functions/partials/IncludeCached.md similarity index 88% rename from content/en/functions/partialCached.md rename to content/en/functions/partials/IncludeCached.md index 5084fc44d..ab9a77835 100644 --- a/content/en/functions/partialCached.md +++ b/content/en/functions/partials/IncludeCached.md @@ -1,18 +1,23 @@ --- -title: partialCached +title: partials.IncludeCached +linkTitle: partialCached description: Allows for caching of partials that do not need to be re-rendered on every invocation. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: partials -relatedFuncs: +function: + aliases: [partialCached] + returnType: any + signatures: ['partials.IncludeCached LAYOUT CONTEXT [VARIANT...]'] +relatedFunctions: - partials.Include - partials.IncludeCached -signature: +signatures: - partials.IncludeCached LAYOUT CONTEXT [VARIANT...] - partialCached LAYOUT CONTEXT [VARIANT...] +aliases: [/functions/partialcached] --- The `partialCached` template function can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation. diff --git a/content/en/functions/path.Base.md b/content/en/functions/path/Base.md similarity index 82% rename from content/en/functions/path.Base.md rename to content/en/functions/path/Base.md index 785f5347e..c00873524 100644 --- a/content/en/functions/path.Base.md +++ b/content/en/functions/path/Base.md @@ -2,12 +2,15 @@ title: path.Base description: Base returns the last element of a path. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.Base PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.Base PATH +aliases: [/functions/path.base] --- `path.Base` returns the last element of `PATH`. diff --git a/content/en/functions/path.BaseName.md b/content/en/functions/path/BaseName.md similarity index 81% rename from content/en/functions/path.BaseName.md rename to content/en/functions/path/BaseName.md index 54aa8bde7..a357ed403 100644 --- a/content/en/functions/path.BaseName.md +++ b/content/en/functions/path/BaseName.md @@ -2,12 +2,15 @@ title: path.BaseName description: BaseName returns the last element of a path, removing the extension if present. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.BaseName PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.BaseName PATH +aliases: [/functions/path.basename] --- If `PATH` is empty, `.` is returned. diff --git a/content/en/functions/path.Clean.md b/content/en/functions/path/Clean.md similarity index 83% rename from content/en/functions/path.Clean.md rename to content/en/functions/path/Clean.md index 866f17b76..98160c568 100644 --- a/content/en/functions/path.Clean.md +++ b/content/en/functions/path/Clean.md @@ -2,12 +2,15 @@ title: path.Clean description: Replaces path separators with slashes (`/`) and removes extraneous separators. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.Clean PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.Clean PATH +aliases: [/functions/path.clean] --- `path.Clean` replaces path separators with slashes (`/`) and removes extraneous separators, including trailing separators. diff --git a/content/en/functions/path.Dir.md b/content/en/functions/path/Dir.md similarity index 84% rename from content/en/functions/path.Dir.md rename to content/en/functions/path/Dir.md index 809128a12..0a2928696 100644 --- a/content/en/functions/path.Dir.md +++ b/content/en/functions/path/Dir.md @@ -2,12 +2,15 @@ title: path.Dir description: Dir returns all but the last element of a path. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.Dir PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.Dir PATH +aliases: [/functions/path.dir] --- `path.Dir` returns all but the last element of `PATH`, typically `PATH`'s directory. diff --git a/content/en/functions/path.Ext.md b/content/en/functions/path/Ext.md similarity index 82% rename from content/en/functions/path.Ext.md rename to content/en/functions/path/Ext.md index 4e157dc3c..6b5685948 100644 --- a/content/en/functions/path.Ext.md +++ b/content/en/functions/path/Ext.md @@ -2,12 +2,15 @@ title: path.Ext description: Ext returns the file name extension of a path. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.Ext PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.Ext PATH +aliases: [/functions/path.ext] --- `path.Ext` returns the file name extension `PATH`. diff --git a/content/en/functions/path.Join.md b/content/en/functions/path/Join.md similarity index 83% rename from content/en/functions/path.Join.md rename to content/en/functions/path/Join.md index 103a15302..4f5c51c0f 100644 --- a/content/en/functions/path.Join.md +++ b/content/en/functions/path/Join.md @@ -2,12 +2,15 @@ title: path.Join description: Join path elements into a single path. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [path.Join ELEMENT...] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -16,8 +19,7 @@ relatedFuncs: - path.Join - path.Split - urls.JoinPath -signature: - - path.Join ELEMENT... +aliases: [/functions/path.join] --- `path.Join` joins path elements into a single path, adding a separating slash if necessary. diff --git a/content/en/functions/path.Split.md b/content/en/functions/path/Split.md similarity index 59% rename from content/en/functions/path.Split.md rename to content/en/functions/path/Split.md index 2b36faefb..bde412743 100644 --- a/content/en/functions/path.Split.md +++ b/content/en/functions/path/Split.md @@ -2,12 +2,15 @@ title: path.Split description: Split path immediately following the final slash. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: path -relatedFuncs: +function: + aliases: [] + returnType: DirFile + signatures: [path.Split PATH] +relatedFunctions: - path.Base - path.BaseName - path.Clean @@ -15,8 +18,7 @@ relatedFuncs: - path.Ext - path.Join - path.Split -signature: - - path.Split PATH +aliases: [/functions/path.split] --- `path.Split` splits `PATH` immediately following the final slash, separating it into a directory and a base component. @@ -27,7 +29,15 @@ If there is no slash in `PATH`, it returns an empty directory and the base is se **Note:** On Windows, `PATH` is converted to slash (`/`) separators. ```go-html-template -{{ $dirFile := path.Split "a/news.html" }} → $dirFile.Dir → "a/", $dirFile.File → "news.html" -{{ $dirFile := path.Split "news.html" }} → $dirFile.Dir → "", $dirFile.File → "news.html" -{{ $dirFile := path.Split "a/b/c" }} → $dirFile.Dir → "a/b/", $dirFile.File → "c" +{{ $dirFile := path.Split "a/news.html" }} +{{ $dirFile.Dir }} → "a/" +{{ $dirFile.File }} → "news.html" + +{{ $dirFile := path.Split "news.html" }} +{{ $dirFile.Dir }} → "" +{{ $dirFile.File }} → "news.html" + +{{ $dirFile := path.Split "a/b/c" }} +{{ $dirFile.Dir }} → "a/b/" +{{ $dirFile.File }} → "c" ``` diff --git a/content/en/functions/range.md b/content/en/functions/range.md deleted file mode 100644 index 7b8d7bc75..000000000 --- a/content/en/functions/range.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: range -description: Iterates over a map, array, or slice. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: text/template -relatedFuncs: - - with - - range -signature: - - range COLLECTION ---- - -Just like in the Go programming language, Go and Hugo templates make heavy use of `range` to iterate over a map, array or slice. Other templating languages use a foreach for the equivalent functionality. - -`range` is fundamental to templating in Hugo. (See the [Introduction to Hugo Templates](/templates/introduction/) for more examples.) diff --git a/content/en/functions/reflect.IsMap.md b/content/en/functions/reflect/IsMap.md similarity index 59% rename from content/en/functions/reflect.IsMap.md rename to content/en/functions/reflect/IsMap.md index fa846f3b8..7d89bb38a 100644 --- a/content/en/functions/reflect.IsMap.md +++ b/content/en/functions/reflect/IsMap.md @@ -1,21 +1,22 @@ --- title: reflect.IsMap -description: Reports if a value is a map. +description: Reports whether the value is a map. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] +function: + aliases: [] + returnType: bool + signatures: [reflect.IsMap INPUT] namespace: reflect -relatedFuncs: +relatedFunctions: - reflect.IsMap - reflect.IsSlice -signature: - - reflect.IsMap INPUT +aliases: [/functions/reflect.ismap] --- -`reflect.IsMap` reports if `VALUE` is a map. Returns a boolean. - ```go-html-template {{ reflect.IsMap (dict "key" "value") }} → true {{ reflect.IsMap "yo" }} → false diff --git a/content/en/functions/reflect.IsSlice.md b/content/en/functions/reflect/IsSlice.md similarity index 58% rename from content/en/functions/reflect.IsSlice.md rename to content/en/functions/reflect/IsSlice.md index 09a311859..09bab7127 100644 --- a/content/en/functions/reflect.IsSlice.md +++ b/content/en/functions/reflect/IsSlice.md @@ -1,21 +1,22 @@ --- title: reflect.IsSlice -description: Reports if a value is a slice. +description: Reports whether the value is a slice. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] +function: + aliases: [] + returnType: bool + signatures: [reflect.IsSlice INPUT] namespace: reflect -relatedFuncs: +relatedFunctions: - reflect.IsMap - reflect.IsSlice -signature: - - reflect.IsSlice INPUT +aliases: [/functions/reflect.isslice] --- -`reflect.IsSlice` reports if `VALUE` is a slice. Returns a boolean. - ```go-html-template {{ reflect.IsSlice (slice 1 2 3) }} → true {{ reflect.IsSlice "yo" }} → false diff --git a/content/en/functions/safeCSS.md b/content/en/functions/safe/CSS.md similarity index 85% rename from content/en/functions/safeCSS.md rename to content/en/functions/safe/CSS.md index 197c7c25e..d5dcdfb66 100644 --- a/content/en/functions/safeCSS.md +++ b/content/en/functions/safe/CSS.md @@ -1,22 +1,24 @@ --- -title: safeCSS +title: safe.CSS +linkTitle: safeCSS description: Declares the provided string as a known "safe" CSS string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeCSS] + returnType: template.CSS + signatures: [safe.CSS INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.CSS INPUT - - safeCSS INPUT +aliases: [/functions/safecss] --- In this context, *safe* means CSS content that matches any of the following: diff --git a/content/en/functions/safeHTML.md b/content/en/functions/safe/HTML.md similarity index 86% rename from content/en/functions/safeHTML.md rename to content/en/functions/safe/HTML.md index 9d981411e..ea3afe8f3 100644 --- a/content/en/functions/safeHTML.md +++ b/content/en/functions/safe/HTML.md @@ -1,22 +1,24 @@ --- -title: safeHTML +title: safe.HTML +linkTitle: safeHTML description: Declares a provided string as a "safe" HTML document to avoid escaping by Go templates. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeHTML] + returnType: template.HTML + signatures: [safe.HTML INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.HTML INPUT - - safeHTML INPUT +aliases: [/functions/safehtml] --- It should not be used for HTML from a third-party, or HTML with unclosed tags or comments. diff --git a/content/en/functions/safeHTMLAttr.md b/content/en/functions/safe/HTMLAttr.md similarity index 85% rename from content/en/functions/safeHTMLAttr.md rename to content/en/functions/safe/HTMLAttr.md index 7efd7b651..7d1b06c47 100644 --- a/content/en/functions/safeHTMLAttr.md +++ b/content/en/functions/safe/HTMLAttr.md @@ -1,22 +1,24 @@ --- -title: safeHTMLAttr +title: safe.HTMLAttr +linkTitle: safeHTMLAttr description: Declares the provided string as a safe HTML attribute. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeHTMLAttr] + returnType: template.HTMLAttr + signatures: [safe.HTMLAttr INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.HTMLAttr INPUT - - safeHTMLAttr INPUT +aliases: [/functions/safehtmlattr] --- Given a site configuration that contains this menu entry: diff --git a/content/en/functions/safeJS.md b/content/en/functions/safe/JS.md similarity index 85% rename from content/en/functions/safeJS.md rename to content/en/functions/safe/JS.md index ae47cb56a..e679b5f85 100644 --- a/content/en/functions/safeJS.md +++ b/content/en/functions/safe/JS.md @@ -1,22 +1,24 @@ --- -title: safeJS +title: safe.JS +linkTitle: safeJS description: Declares the provided string as a known safe JavaScript string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeJS] + returnType: template.JS + signatures: [safe.JS INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.JS INPUT - - safeJS INPUT +aliases: [/functions/safejs] --- In this context, *safe* means the string encapsulates a known safe EcmaScript5 Expression (e.g., `(x + y * z())`). diff --git a/content/en/functions/safeJSStr.md b/content/en/functions/safe/JSStr.md similarity index 85% rename from content/en/functions/safeJSStr.md rename to content/en/functions/safe/JSStr.md index 1b62b1d5f..790de3a73 100644 --- a/content/en/functions/safeJSStr.md +++ b/content/en/functions/safe/JSStr.md @@ -1,22 +1,24 @@ --- -title: safeJSStr +title: safe.JSStr +linkTitle: safeJSStr description: Declares the provided string as a known safe JavaScript string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeJSStr] + returnType: template.JSStr + signatures: [safe.JSStr INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.JSStr INPUT - - safeJSStr INPUT +aliases: [/functions/safejsstr] --- Encapsulates a sequence of characters meant to be embedded between quotes in a JavaScript expression. Use of this type presents a security risk: the encapsulated content should come from a trusted source, as it will be included verbatim in the template output. diff --git a/content/en/functions/safeURL.md b/content/en/functions/safe/URL.md similarity index 93% rename from content/en/functions/safeURL.md rename to content/en/functions/safe/URL.md index 417bb7a7b..edc62ff9d 100644 --- a/content/en/functions/safeURL.md +++ b/content/en/functions/safe/URL.md @@ -1,23 +1,24 @@ --- -title: safeURL +title: safe.URL +linkTitle: safeURL description: Declares the provided string as a safe URL or URL substring. -keywords: [strings,urls] categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: safe -relatedFuncs: +function: + aliases: [safeURL] + returnType: template.URL + signatures: [safe.URL INPUT] +relatedFunctions: - safe.CSS - safe.HTML - safe.HTMLAttr - safe.JS - safe.JSStr - safe.URL -signature: - - safe.URL INPUT - - safeURL INPUT +aliases: [/functions/safeurl] --- `safeURL` declares the provided string as a "safe" URL or URL substring (see [RFC 3986]). A URL like `javascript:checkThatFormNotEditedBeforeLeavingPage()` from a trusted source should go in the page, but by default dynamic `javascript:` URLs are filtered out since they are a frequently exploited injection vector. diff --git a/content/en/functions/site.md b/content/en/functions/site/index.md similarity index 84% rename from content/en/functions/site.md rename to content/en/functions/site/index.md index 522375588..3341bff98 100644 --- a/content/en/functions/site.md +++ b/content/en/functions/site/index.md @@ -2,15 +2,19 @@ title: site description: Provides global access to the .Site object. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: global -relatedFuncs: +function: + aliases: [] + returnType: + signatures: [site] +relatedFunctions: + - hugo - page - site -signature: [site] +aliases: [/functions/site] --- At the top level of a template that receives the `Site` object in context, these are equivalent: @@ -28,5 +32,4 @@ When the `Site` object is not in context, use the global `site` function: {{% note %}} To simplify your templates, use the global `site` function regardless of whether the `Site` object is in context. - {{% /note %}} diff --git a/content/en/functions/slicestr.md b/content/en/functions/slicestr.md deleted file mode 100644 index 2b088e493..000000000 --- a/content/en/functions/slicestr.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: slicestr -description: Creates a slice of a half-open range, including start and end indices. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: strings -relatedFuncs: [] -signature: - - strings.SliceString STRING START [END] - - slicestr STRING START [END] ---- - -For example, 1 and 4 creates a slice including elements 1 through 3. -The `end` index can be omitted; it defaults to the string's length. - -* `{{ slicestr "BatMan" 3 }}` → "Man" -* `{{ slicestr "BatMan" 0 3 }}` → "Bat" diff --git a/content/en/functions/strings.Repeat.md b/content/en/functions/strings.Repeat.md deleted file mode 100644 index 8578cf8cc..000000000 --- a/content/en/functions/strings.Repeat.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: strings.Repeat -description: Returns INPUT repeated COUNT times. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: strings -relatedFuncs: [] -signature: - - strings.Repeat COUNT INPUT ---- - -```go-html-template -{{ strings.Repeat 3 "yo" }} → "yoyoyo" -{{ "yo" | strings.Repeat 3 }} → "yoyoyo" -``` diff --git a/content/en/functions/strings.RuneCount.md b/content/en/functions/strings.RuneCount.md deleted file mode 100644 index c80d86e42..000000000 --- a/content/en/functions/strings.RuneCount.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: strings.RuneCount -description: Determines the number of runes in a string. -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: strings -relatedFuncs: - - len - - strings.Count - - strings.CountRunes - - strings.CountWords - - strings.RuneCount -signature: - - strings.RuneCount INPUT ---- - -In contrast with `strings.CountRunes` function, which strips HTML and whitespace before counting runes, `strings.RuneCount` simply counts all the runes in a string. It relies on the Go [`utf8.RuneCountInString`] function. - -```go-html-template -{{ "Hello, 世界" | strings.RuneCount }} - -``` - -[`utf8.RuneCount`]: https://golang.org/pkg/unicode/utf8/#RuneCount diff --git a/content/en/functions/chomp.md b/content/en/functions/strings/Chomp.md similarity index 58% rename from content/en/functions/chomp.md rename to content/en/functions/strings/Chomp.md index 012c58b6d..22e2b546b 100644 --- a/content/en/functions/chomp.md +++ b/content/en/functions/strings/Chomp.md @@ -1,26 +1,30 @@ --- title: chomp -toc: true +linkTitle: chomp description: Removes any trailing newline characters. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [chomp] + returnType: any + signatures: [strings.Chomp STRING] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - chomp STRING - - strings.Chomp STRING +aliases: [/functions/chomp] --- -Useful in a pipeline to remove newlines added by other processing (e.g., [`markdownify`](/functions/markdownify/)). +If the argument is of type template.HTML, returns template.HTML, else returns a string. + + +Useful in a pipeline to remove newlines added by other processing (e.g., [`markdownify`](/functions/transform/markdownify)). ```go-html-template {{ chomp "

Blockhead

\n" }} → "

Blockhead

" diff --git a/content/en/functions/strings.Contains.md b/content/en/functions/strings/Contains.md similarity index 64% rename from content/en/functions/strings.Contains.md rename to content/en/functions/strings/Contains.md index d37a6b536..66a90aeea 100644 --- a/content/en/functions/strings.Contains.md +++ b/content/en/functions/strings/Contains.md @@ -1,21 +1,22 @@ --- title: strings.Contains -description: Reports whether a string contains a substring. +description: Reports whether the string contains a substring. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: bool + signatures: [strings.Contains STRING SUBSTRING] +relatedFunctions: - strings.Contains - strings.ContainsAny - strings.ContainsNonSpace - strings.HasPrefix - strings.HasSuffix - - collections.In -signature: - - strings.Contains STRING SUBSTRING +aliases: [/functions/strings.contains] --- ```go-html-template diff --git a/content/en/functions/strings.ContainsAny.md b/content/en/functions/strings/ContainsAny.md similarity index 74% rename from content/en/functions/strings.ContainsAny.md rename to content/en/functions/strings/ContainsAny.md index 281f6ec7d..4f324358a 100644 --- a/content/en/functions/strings.ContainsAny.md +++ b/content/en/functions/strings/ContainsAny.md @@ -2,25 +2,26 @@ title: strings.ContainsAny description: Reports whether a string contains any character from a given string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: bool + signatures: [strings.ContainsAny STRING CHARACTERS] +relatedFunctions: - strings.Contains - strings.ContainsAny - strings.ContainsNonSpace - strings.HasPrefix - strings.HasSuffix - - collections.In -signature: - - strings.ContainsAny STRING CHARACTERS +aliases: [/functions/strings.containsany] --- ```go-html-template {{ strings.ContainsAny "Hugo" "gm" }} → true ---- +``` The check is case sensitive: diff --git a/content/en/functions/strings.ContainsNonSpace.md b/content/en/functions/strings/ContainsNonSpace.md similarity index 82% rename from content/en/functions/strings.ContainsNonSpace.md rename to content/en/functions/strings/ContainsNonSpace.md index c8dcc1a45..d2e6114b3 100644 --- a/content/en/functions/strings.ContainsNonSpace.md +++ b/content/en/functions/strings/ContainsNonSpace.md @@ -2,20 +2,21 @@ title: strings.ContainsNonSpace description: Reports whether a string contains any non-space characters as defined by Unicode’s White Space property. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: bool + signatures: [strings.ContainsNonSpace STRING] +relatedFunctions: - strings.Contains - strings.ContainsAny - strings.ContainsNonSpace - strings.HasPrefix - strings.HasSuffix - - collections.In -signature: - - strings.ContainsNonSpace STRING +aliases: [/functions/strings.containsnonspace] --- ```go-html-template diff --git a/content/en/functions/strings.Count.md b/content/en/functions/strings/Count.md similarity index 54% rename from content/en/functions/strings.Count.md rename to content/en/functions/strings/Count.md index 152685355..25ea58967 100644 --- a/content/en/functions/strings.Count.md +++ b/content/en/functions/strings/Count.md @@ -2,26 +2,28 @@ title: strings.Count description: Returns the number of non-overlapping instances of a substring within a string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: int + signatures: [strings.Count SUBSTR STRING] +relatedFunctions: - len - strings.Count - strings.CountRunes - strings.CountWords - strings.RuneCount -signature: - - strings.Count SUBSTR STRING +aliases: [/functions/strings.count] --- If `SUBSTR` is an empty string, this function returns 1 plus the number of Unicode code points in `STRING`. -Example|Result -:--|:-- -`{{ "aaabaab" \| strings.Count "a" }}`|5 -`{{ "aaabaab" \| strings.Count "aa" }}`|2 -`{{ "aaabaab" \| strings.Count "aaa" }}`|1 -`{{ "aaabaab" \| strings.Count "" }}`|8 +```go-html-template +{{ "aaabaab" | strings.Count "a" }} → 5 +{{ "aaabaab" | strings.Count "aa" }} → 2 +{{ "aaabaab" | strings.Count "aaa" }} → 1 +{{ "aaabaab" | strings.Count "" }} → 8 +``` diff --git a/content/en/functions/strings/CountRunes.md b/content/en/functions/strings/CountRunes.md new file mode 100644 index 000000000..4a17d04ab --- /dev/null +++ b/content/en/functions/strings/CountRunes.md @@ -0,0 +1,29 @@ +--- +title: strings.CountRunes +linkTitle: countrunes +description: Returns the number of runes in a string excluding whitespace. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [countrunes] + returnType: int + signatures: [strings.CountRunes INPUT] +relatedFunctions: + - len + - strings.Count + - strings.CountRunes + - strings.CountWords + - strings.RuneCount +aliases: [/functions/countrunes] +--- + +In contrast with the [`strings.RuneCount`] function, which counts every rune in a string, `strings.CountRunes` excludes whitespace. + +```go-html-template +{{ "Hello, 世界" | strings.CountRunes }} → 8 +``` + +[`strings.RuneCount`]: /functions/strings/runecount diff --git a/content/en/functions/countwords.md b/content/en/functions/strings/CountWords.md similarity index 70% rename from content/en/functions/countwords.md rename to content/en/functions/strings/CountWords.md index a7b06debe..e6915e6cd 100644 --- a/content/en/functions/countwords.md +++ b/content/en/functions/strings/CountWords.md @@ -1,21 +1,23 @@ --- -title: countwords +title: strings.CountWords +linkTitle: countwords description: Counts the number of words in a string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [countwords] + returnType: int + signatures: [strings.CountWords INPUT] +relatedFunctions: - len - strings.Count - strings.CountRunes - strings.CountWords - strings.RuneCount -signature: - - strings.CountWords INPUT - - countwords INPUT +aliases: [/functions/countwords] --- The template function works similar to the [.WordCount page variable][pagevars]. diff --git a/content/en/functions/findresubmatch.md b/content/en/functions/strings/FindRESubmatch.md similarity index 86% rename from content/en/functions/findresubmatch.md rename to content/en/functions/strings/FindRESubmatch.md index 9a374ea4e..5a0410fdb 100644 --- a/content/en/functions/findresubmatch.md +++ b/content/en/functions/strings/FindRESubmatch.md @@ -1,25 +1,27 @@ --- -title: findRESubmatch +title: strings.FindRESubmatch +linkTitle: findRESubmatch description: Returns a slice of all successive matches of the regular expression. Each element is a slice of strings holding the text of the leftmost match of the regular expression and the matches, if any, of its subexpressions. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [findRESubmatch] + returnType: '[]string' + signatures: ['strings.FindRESubmatch PATTERN INPUT [LIMIT]'] +relatedFunctions: - strings.FindRE - strings.FindRESubmatch - strings.Replace - strings.ReplaceRE -signature: - - strings.FindRESubmatch PATTERN INPUT [LIMIT - - findRESubmatch PATTERN INPUT [LIMIT] +aliases: [/functions/findresubmatch] --- By default, `findRESubmatch` finds all matches. You can limit the number of matches with an optional LIMIT argument. A return value of nil indicates no match. -{{% readfile file="/functions/common/regular-expressions.md" %}} +{{% readfile file="/functions/_common/regular-expressions.md" %}} ## Demonstrative examples diff --git a/content/en/functions/findRe.md b/content/en/functions/strings/FindRe.md similarity index 78% rename from content/en/functions/findRe.md rename to content/en/functions/strings/FindRe.md index c5d26c3a4..4a7811f3d 100644 --- a/content/en/functions/findRe.md +++ b/content/en/functions/strings/FindRe.md @@ -1,24 +1,26 @@ --- -title: findRE +title: strings.FindRE +linkTitle: findRE description: Returns a slice of strings that match the regular expression. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [findRE] + returnType: string + signatures: ['strings.FindRE PATTERN INPUT [LIMIT]'] +relatedFunctions: - strings.FindRE - strings.FindRESubmatch - strings.Replace - strings.ReplaceRE -signature: - - strings.FindRE PATTERN INPUT [LIMIT] - - findRE PATTERN INPUT [LIMIT] +aliases: [/functions/findre] --- By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT argument. -{{% readfile file="/functions/common/regular-expressions.md" %}} +{{% readfile file="/functions/_common/regular-expressions.md" %}} This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`: diff --git a/content/en/functions/strings.FirstUpper.md b/content/en/functions/strings/FirstUpper.md similarity index 68% rename from content/en/functions/strings.FirstUpper.md rename to content/en/functions/strings/FirstUpper.md index 1cb38386c..320f01eda 100644 --- a/content/en/functions/strings.FirstUpper.md +++ b/content/en/functions/strings/FirstUpper.md @@ -2,18 +2,20 @@ title: strings.FirstUpper description: Capitalizes the first character of a given string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [strings.FirstUpper STRING] +relatedFunctions: - strings.FirstUpper - strings.Title - strings.ToLower - strings.ToUpper -signature: - - strings.FirstUpper STRING +aliases: [/functions/strings.firstupper] --- ```go-html-template diff --git a/content/en/functions/strings.HasPrefix.md b/content/en/functions/strings/HasPrefix.md similarity index 54% rename from content/en/functions/strings.HasPrefix.md rename to content/en/functions/strings/HasPrefix.md index 332050b7e..88a79a935 100644 --- a/content/en/functions/strings.HasPrefix.md +++ b/content/en/functions/strings/HasPrefix.md @@ -1,23 +1,22 @@ --- title: strings.HasPrefix -description: Tests whether a string begins with prefix. +description: Reports whether a string begins with prefix. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [hasPrefix] + returnType: bool + signatures: [strings.HasPrefix STRING PREFIX] +relatedFunctions: - strings.Contains - strings.ContainsAny - strings.ContainsNonSpace - strings.HasPrefix - strings.HasSuffix - - collections.In -signature: - - strings.HasPrefix STRING PREFIX - - hasPrefix STRING PREFIX -aliases: [/functions/hasprefix/] +aliases: [/functions/hasprefix,/functions/strings.hasprefix] --- ```go-html-template diff --git a/content/en/functions/strings.HasSuffix.md b/content/en/functions/strings/HasSuffix.md similarity index 54% rename from content/en/functions/strings.HasSuffix.md rename to content/en/functions/strings/HasSuffix.md index 5ba29a550..d11f3e8cf 100644 --- a/content/en/functions/strings.HasSuffix.md +++ b/content/en/functions/strings/HasSuffix.md @@ -1,23 +1,22 @@ --- title: strings.HasSuffix -description: Tests whether a string ends with suffix. +description: Reports whether a string ends with suffix. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [hasSuffix] + returnType: bool + signatures: [strings.HasSuffix STRING SUFFIX] +relatedFunctions: - strings.Contains - strings.ContainsAny - strings.ContainsNonSpace - strings.HasPrefix - strings.HasSuffix - - collections.In -signature: - - strings.HasSuffix STRING SUFFIX - - hasSuffix STRING SUFFIX -aliases: [/functions/hassuffix/] +aliases: [/functions/hassuffix,/functions/strings/hassuffix] --- ```go-html-template diff --git a/content/en/functions/strings/Repeat.md b/content/en/functions/strings/Repeat.md new file mode 100644 index 000000000..718f24984 --- /dev/null +++ b/content/en/functions/strings/Repeat.md @@ -0,0 +1,20 @@ +--- +title: strings.Repeat +description: Returns a new string consisting of zero or more copies of another string. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: string + signatures: [strings.Repeat COUNT INPUT] +relatedFunctions: [] +aliases: [/functions/strings.repeat] +--- + +```go-html-template +{{ strings.Repeat 3 "yo" }} → "yoyoyo" +{{ "yo" | strings.Repeat 3 }} → "yoyoyo" +``` diff --git a/content/en/functions/replace.md b/content/en/functions/strings/Replace.md similarity index 66% rename from content/en/functions/replace.md rename to content/en/functions/strings/Replace.md index da58f9cb2..8d5e54859 100644 --- a/content/en/functions/replace.md +++ b/content/en/functions/strings/Replace.md @@ -1,27 +1,29 @@ --- -title: replace +title: strings.Replace +linkTitle: replace description: Replaces all occurrences of the search string with the replacement string. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [replace] + returnType: string + signatures: ['strings.Replace INPUT OLD NEW [LIMIT]'] +relatedFunctions: - strings.FindRE - strings.FindRESubmatch - strings.Replace - strings.ReplaceRE -signature: - - strings.Replace INPUT OLD NEW [LIMIT] - - replace INPUT OLD NEW [LIMIT] +aliases: [/functions/replace] --- Replace returns a copy of `INPUT` with all occurrences of `OLD` replaced with `NEW`. The number of replacements can be limited with an optional `LIMIT` argument. ``` -`{{ replace "Batman and Robin" "Robin" "Catwoman" }}` +{{ replace "Batman and Robin" "Robin" "Catwoman" }} → "Batman and Catwoman" {{ replace "aabbaabb" "a" "z" 2 }} → "zzbbaabb" diff --git a/content/en/functions/replacere.md b/content/en/functions/strings/ReplaceRE.md similarity index 81% rename from content/en/functions/replacere.md rename to content/en/functions/strings/ReplaceRE.md index 4116e57d2..247595877 100644 --- a/content/en/functions/replacere.md +++ b/content/en/functions/strings/ReplaceRE.md @@ -1,24 +1,26 @@ --- -title: replaceRE +title: strings.ReplaceRE +linkTitle: replaceRE description: Returns a string, replacing all occurrences of a regular expression with a replacement pattern. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [replaceRE] + returnType: string + signatures: ['strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]'] +relatedFunctions: - strings.FindRE - strings.FindRESubmatch - strings.Replace - strings.ReplaceRE -signature: - - strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT] - - replaceRE PATTERN REPLACEMENT INPUT [LIMIT] +aliases: [/functions/replacere] --- By default, `replaceRE` replaces all matches. You can limit the number of matches with an optional LIMIT argument. -{{% readfile file="/functions/common/regular-expressions.md" %}} +{{% readfile file="/functions/_common/regular-expressions.md" %}} This example replaces two or more consecutive hyphens with a single hyphen: diff --git a/content/en/functions/strings/RuneCount.md b/content/en/functions/strings/RuneCount.md new file mode 100644 index 000000000..a4d5a8dbe --- /dev/null +++ b/content/en/functions/strings/RuneCount.md @@ -0,0 +1,28 @@ +--- +title: strings.RuneCount +description: Returns the number of runes in a string. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: int + signatures: [strings.RuneCount INPUT] +relatedFunctions: + - len + - strings.Count + - strings.CountRunes + - strings.CountWords + - strings.RuneCount +aliases: [/functions/strings.runecount] +--- + +In contrast with the [`strings.CountRunes`] function, which excludes whitespace, `strings.RuneCount` counts every rune in a string. + +```go-html-template +{{ "Hello, 世界" | strings.RuneCount }} → 9 +``` + +[`strings.CountRunes`]: /functions/strings/countrunes diff --git a/content/en/functions/strings/SliceString.md b/content/en/functions/strings/SliceString.md new file mode 100644 index 000000000..8d26d76e4 --- /dev/null +++ b/content/en/functions/strings/SliceString.md @@ -0,0 +1,24 @@ +--- +title: strings.SliceString +linkTitle: slicestr +description: Creates a slice of a half-open range, including start and end indices. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [slicestr] + returnType: string + signatures: ['strings.SliceString STRING START [END]'] +relatedFunctions: [] +aliases: [/functions/slicestr] +--- + +For example, 1 and 4 creates a slice including elements 1 through 3. +The `end` index can be omitted; it defaults to the string's length. + +```go-html-template +{{ slicestr "BatMan" 3 }}` → "Man" +{{ slicestr "BatMan" 0 3 }}` → "Bat" +``` diff --git a/content/en/functions/split.md b/content/en/functions/strings/Split.md similarity index 50% rename from content/en/functions/split.md rename to content/en/functions/strings/Split.md index d5d089b77..7d15704b2 100644 --- a/content/en/functions/split.md +++ b/content/en/functions/strings/Split.md @@ -1,18 +1,20 @@ --- -title: split +title: strings.Split +linkTitle: split description: Returns a slice of strings by splitting STRING by DELIM. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [split] + returnType: string + signatures: [strings.Split STRING DELIM] +relatedFunctions: - collections.Delimit - strings.Split -signature: - - strings.Split STRING DELIM - - split STRING DELIM +aliases: [/functions/split] --- Examples: @@ -24,5 +26,5 @@ Examples: {{% note %}} -`split` essentially does the opposite of [delimit](/functions/delimit). While `split` creates a slice from a string, `delimit` creates a string from a slice. +`split` essentially does the opposite of [delimit](/functions/collections/delimit). While `split` creates a slice from a string, `delimit` creates a string from a slice. {{% /note %}} diff --git a/content/en/functions/substr.md b/content/en/functions/strings/Substr.md similarity index 84% rename from content/en/functions/substr.md rename to content/en/functions/strings/Substr.md index 6bdb10126..9dafa0737 100644 --- a/content/en/functions/substr.md +++ b/content/en/functions/strings/Substr.md @@ -1,16 +1,18 @@ --- -title: substr +title: strings.Substr +linkTitle: substr description: Extracts parts of a string from a specified character's position and returns the specified number of characters. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: [] -signature: - - substr STRING START [LENGTH] - - strings.Substr STRING START [LENGTH] +function: + aliases: [substr] + returnType: string + signatures: ['strings.Substr STRING START [LENGTH]'] +relatedFunctions: [] +aliases: [/functions/substr] --- It normally takes two argument: `start` and `length`. It can also take one argument: `start`, i.e. `length` is omitted, in which case the substring starting from start until the end of the string will be returned. diff --git a/content/en/functions/title.md b/content/en/functions/strings/Title.md similarity index 81% rename from content/en/functions/title.md rename to content/en/functions/strings/Title.md index 80627cf5d..1e20d1f59 100644 --- a/content/en/functions/title.md +++ b/content/en/functions/strings/Title.md @@ -1,20 +1,22 @@ --- -title: title +title: strings.Title +linkTitle: title description: Converts the provided string to title case. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [title] + returnType: string + signatures: [strings.Title STRING] +relatedFunctions: - strings.FirstUpper - strings.Title - strings.ToLower - strings.ToUpper -signature: - - strings.Title STRING - - title STRING +aliases: [/functions/title] --- ```go-html-template diff --git a/content/en/functions/lower.md b/content/en/functions/strings/ToLower.md similarity index 70% rename from content/en/functions/lower.md rename to content/en/functions/strings/ToLower.md index 04d60b334..cb76462ea 100644 --- a/content/en/functions/lower.md +++ b/content/en/functions/strings/ToLower.md @@ -1,20 +1,22 @@ --- -title: lower +title: strings.ToLower +linkTitle: lower description: Converts all characters in the provided string to lowercase. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [lower] + returnType: string + signatures: [strings.ToLower INPUT] +relatedFunctions: - strings.FirstUpper - strings.Title - strings.ToLower - strings.ToUpper -signature: - - strings.ToLower INPUT - - lower INPUT +aliases: [/functions/lower] --- diff --git a/content/en/functions/upper.md b/content/en/functions/strings/ToUpper.md similarity index 69% rename from content/en/functions/upper.md rename to content/en/functions/strings/ToUpper.md index 73e861525..d46491637 100644 --- a/content/en/functions/upper.md +++ b/content/en/functions/strings/ToUpper.md @@ -1,21 +1,22 @@ --- -title: upper +title: strings.ToUpper +linkTitle: upper description: Converts all characters in a string to uppercase - categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [upper] + returnType: string + signatures: [strings.ToUpper INPUT] +relatedFunctions: - strings.FirstUpper - strings.Title - strings.ToLower - strings.ToUpper -signature: - - strings.ToUpper INPUT - - upper INPUT +aliases: [/functions/upper] --- Note that `upper` can be applied in your templates in more than one way: diff --git a/content/en/functions/trim.md b/content/en/functions/strings/Trim.md similarity index 86% rename from content/en/functions/trim.md rename to content/en/functions/strings/Trim.md index a2048c832..9eae9ee45 100644 --- a/content/en/functions/trim.md +++ b/content/en/functions/strings/Trim.md @@ -1,22 +1,24 @@ --- -title: trim +title: strings.Trim +linkTitle: trim description: Returns a slice of a passed string with all leading and trailing characters from cutset removed. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [title] + returnType: string + signatures: [strings.Trim INPUT CUTSET] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - strings.Trim INPUT CUTSET - - trim INPUT CUTSET +aliases: [/functions/trim] --- ```go-html-template diff --git a/content/en/functions/strings.TrimLeft.md b/content/en/functions/strings/TrimLeft.md similarity index 79% rename from content/en/functions/strings.TrimLeft.md rename to content/en/functions/strings/TrimLeft.md index a718e62a3..3924e492f 100644 --- a/content/en/functions/strings.TrimLeft.md +++ b/content/en/functions/strings/TrimLeft.md @@ -2,20 +2,22 @@ title: strings.TrimLeft description: Returns a slice of a given string with all leading characters contained in the cutset removed. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [strings.TrimLeft CUTSET STRING] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - strings.TrimLeft CUTSET STRING +aliases: [/functions/strings.trimleft] --- Given the string `"abba"`, leading `"a"`'s can be removed a follows: diff --git a/content/en/functions/strings.TrimPrefix.md b/content/en/functions/strings/TrimPrefix.md similarity index 80% rename from content/en/functions/strings.TrimPrefix.md rename to content/en/functions/strings/TrimPrefix.md index 661533e55..37657732d 100644 --- a/content/en/functions/strings.TrimPrefix.md +++ b/content/en/functions/strings/TrimPrefix.md @@ -2,20 +2,22 @@ title: strings.TrimPrefix description: Returns a given string s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [strings.TrimPrefix PREFIX STRING] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - strings.TrimPrefix PREFIX STRING +aliases: [/functions/strings.trimprefix] --- Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it: diff --git a/content/en/functions/strings.TrimRight.md b/content/en/functions/strings/TrimRight.md similarity index 79% rename from content/en/functions/strings.TrimRight.md rename to content/en/functions/strings/TrimRight.md index 19c3a6b6d..fa538b605 100644 --- a/content/en/functions/strings.TrimRight.md +++ b/content/en/functions/strings/TrimRight.md @@ -2,20 +2,22 @@ title: strings.TrimRight description: Returns a slice of a given string with all trailing characters contained in the cutset removed. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [strings.TrimRight CUTSET STRING] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - strings.TrimRight CUTSET STRING +aliases: [/functions/strings.trimright] --- Given the string `"abba"`, trailing `"a"`'s can be removed a follows: diff --git a/content/en/functions/strings.TrimSuffix.md b/content/en/functions/strings/TrimSuffix.md similarity index 80% rename from content/en/functions/strings.TrimSuffix.md rename to content/en/functions/strings/TrimSuffix.md index eaf4b1492..6dc9becfc 100644 --- a/content/en/functions/strings.TrimSuffix.md +++ b/content/en/functions/strings/TrimSuffix.md @@ -2,20 +2,22 @@ title: strings.TrimSuffix description: Returns a given string s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: strings -relatedFuncs: +function: + aliases: [] + returnType: string + signatures: [strings.TrimSuffix SUFFIX STRING] +relatedFunctions: - strings.Chomp - strings.Trim - strings.TrimLeft - strings.TrimPrefix - strings.TrimRight - strings.TrimSuffix -signature: - - strings.TrimSuffix SUFFIX STRING +aliases: [/functions/strings.trimsuffix] --- Given the string `"aabbaa"`, the specified suffix is only removed if `"aabbaa"` ends with it: diff --git a/content/en/functions/strings/Truncate.md b/content/en/functions/strings/Truncate.md new file mode 100644 index 000000000..0bd78d840 --- /dev/null +++ b/content/en/functions/strings/Truncate.md @@ -0,0 +1,26 @@ +--- +title: strings.Truncate +linkTitle: truncate +description: Truncates a text to a max length without cutting words or leaving unclosed HTML tags. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [truncate] + returnType: template.HTML + signatures: ['strings.Truncate SIZE [ELLIPSIS] INPUT'] +relatedFunctions: [] +aliases: [/functions/truncate] +--- + +Since Go templates are HTML-aware, `truncate` will intelligently handle normal strings vs HTML strings: + +```go-html-template +{{ "Keep my HTML" | safeHTML | truncate 10 }} → Keep my … +``` + +{{% note %}} +If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML` template function](/functions/safe/html) before sending the value to truncate. Otherwise, the HTML tags will be escaped when passed through the `truncate` function. +{{% /note %}} diff --git a/content/en/functions/symdiff.md b/content/en/functions/symdiff.md deleted file mode 100644 index ad2e29333..000000000 --- a/content/en/functions/symdiff.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: symdiff -description: "`collections.SymDiff` (alias `symdiff`) returns the symmetric difference of two collections." -categories: [functions] -menu: - docs: - parent: functions -keywords: [] -namespace: collections -relatedFuncs: - - collections.Complement - - collections.Intersect - - collections.SymDiff - - collections.Union -signature: - - COLLECTION | collections.SymDiff COLLECTION - - COLLECTION | symdiff COLLECTION ---- - -Example: - -```go-html-template -{{ slice 1 2 3 | symdiff (slice 3 4) }} -``` - -The above will print `[1 2 4]`. - -Also see https://en.wikipedia.org/wiki/Symmetric_difference diff --git a/content/en/functions/templates.Exists.md b/content/en/functions/templates/Exists.md similarity index 73% rename from content/en/functions/templates.Exists.md rename to content/en/functions/templates/Exists.md index 1623583b7..d4a8fab76 100644 --- a/content/en/functions/templates.Exists.md +++ b/content/en/functions/templates/Exists.md @@ -1,15 +1,18 @@ --- title: templates.Exists -description: "Checks whether a template file exists under the given path relative to the `layouts` directory." +description: Reports whether a template file exists under the given path relative to the `layouts` directory. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] +function: + aliases: [] + returnType: bool + signatures: [templates.Exists PATH] namespace: templates -relatedFuncs: [] -signature: - - templates.Exists PATH +relatedFunctions: [] +aliases: [/functions/templates.exists] --- A template file is any file living below the `layouts` directories of either the project or any of its theme components including partials and shortcodes. diff --git a/content/en/functions/time.md b/content/en/functions/time/AsTime.md similarity index 90% rename from content/en/functions/time.md rename to content/en/functions/time/AsTime.md index d534098c9..1244eeb5c 100644 --- a/content/en/functions/time.md +++ b/content/en/functions/time/AsTime.md @@ -1,21 +1,23 @@ --- -title: time +title: time.AsTime +linkTitle: time description: Converts a timestamp string into a `time.Time` structure. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: time -relatedFuncs: +function: + aliases: [time] + returnType: time.Time + signatures: ['time.AsTime INPUT [TIMEZONE]'] +relatedFunctions: - time.AsTime - time.Duration - time.Format - time.Now - time.ParseDuration -signature: - - time.AsTime INPUT [TIMEZONE] - - time INPUT [TIMEZONE] +aliases: [/functions/time] --- @@ -57,6 +59,6 @@ The following example may be useful when setting up [multilingual sites][multili {{< /code >}} -[int]: /functions/int/ +[int]: /functions/cast/toint [multilingual]: /content-management/multilingual/ -[`printf`]: /functions/printf/ +[`printf`]: /functions/fmt/printf diff --git a/content/en/functions/duration.md b/content/en/functions/time/Duration.md similarity index 85% rename from content/en/functions/duration.md rename to content/en/functions/time/Duration.md index fa7b13843..921f25a96 100644 --- a/content/en/functions/duration.md +++ b/content/en/functions/time/Duration.md @@ -1,21 +1,23 @@ --- -title: duration +title: time.Duration +linkTitle: duration description: Returns a `time.Duration` structure, using the given time unit and duration number. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: time -relatedFuncs: +function: + aliases: [duration] + returnType: time.Duration + signatures: [time.Duration TIME_UNIT DURATION_NUMBER] +relatedFunctions: - time.AsTime - time.Duration - time.Format - time.Now - time.ParseDuration -signature: - - time.Duration TIME_UNIT DURATION_NUMBER - - duration TIME_UNIT DURATION_NUMBER +aliases: [/functions/duration] --- `time.Duration` converts a given number into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. E.g. you can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value: diff --git a/content/en/functions/time/Format.md b/content/en/functions/time/Format.md new file mode 100644 index 000000000..3a0b1eb2a --- /dev/null +++ b/content/en/functions/time/Format.md @@ -0,0 +1,76 @@ +--- +title: time.Format +description: Returns a formatted and localized time.Time value. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [dateFormat] + returnType: string + signatures: [time.Format LAYOUT INPUT] +relatedFunctions: + - time.AsTime + - time.Duration + - time.Format + - time.Now + - time.ParseDuration +aliases: [/functions/dateformat] +toc: true +--- + +```go-template +{{ $t := "2023-01-27T23:44:58-08:00" }} +{{ $format := "2 Jan 2006" }} + +{{ $t | time.Format $format }} → 27 Jan 2023 + +{{ $t = time.AsTime $t }} +{{ $t | time.Format $format }} → 27 Jan 2023 +``` + +## Layout string + +{{% readfile file="/functions/_common/time-layout-string.md" %}} + +## Localization + +Use the `time.Format` function to localize `time.Time` values for the current language and region. + +{{% note %}} +{{% readfile file="/functions/_common/locales.md" %}} +{{% /note %}} + + +Use the layout string as described above, or one of the tokens below. For example: + +```go-template +{{ .Date | time.Format ":date_medium" }} → Jan 27, 2023 +``` + +Localized to en-US: + +Token|Result +:--|:-- +`:date_full`|`Friday, January 27, 2023` +`:date_long`|`January 27, 2023` +`:date_medium`|`Jan 27, 2023` +`:date_short`|`1/27/23` +`:time_full`|`11:44:58 pm Pacific Standard Time` +`:time_long`|`11:44:58 pm PST` +`:time_medium`|`11:44:58 pm` +`:time_short`|`11:44 pm` + +Localized to de-DE: + +Token|Result +:--|:-- +`:date_full`|`Freitag, 27. Januar 2023` +`:date_long`|`27. Januar 2023` +`:date_medium`|`27.01.2023` +`:date_short`|`27.01.23` +`:time_full`|`23:44:58 Nordamerikanische Westküsten-Normalzeit` +`:time_long`|`23:44:58 PST` +`:time_medium`|`23:44:58` +`:time_short`|`23:44` diff --git a/content/en/functions/now.md b/content/en/functions/time/Now.md similarity index 87% rename from content/en/functions/now.md rename to content/en/functions/time/Now.md index 032fa1026..74b01ecc5 100644 --- a/content/en/functions/now.md +++ b/content/en/functions/time/Now.md @@ -1,21 +1,23 @@ --- -title: now +title: time.Now +linkTitle: now description: Returns the current local time categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: time -relatedFuncs: +function: + aliases: [now] + returnType: time.Time + signatures: [time.Now] +relatedFunctions: - time.AsTime - time.Duration - time.Format - time.Now - time.ParseDuration -signature: - - time.Now - - now +aliases: [/functions/now] --- See [`time.Time`](https://godoc.org/time#Time). diff --git a/content/en/functions/time.ParseDuration.md b/content/en/functions/time/ParseDuration.md similarity index 85% rename from content/en/functions/time.ParseDuration.md rename to content/en/functions/time/ParseDuration.md index e019648e6..e3abc7c15 100644 --- a/content/en/functions/time.ParseDuration.md +++ b/content/en/functions/time/ParseDuration.md @@ -2,19 +2,21 @@ title: time.ParseDuration description: Parses a given duration string into a `time.Duration` structure. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: time -relatedFuncs: +function: + aliases: [] + returnType: time.Duration + signatures: [time.ParseDuration DURATION] +relatedFunctions: - time.AsTime - time.Duration - time.Format - time.Now - time.ParseDuration -signature: - - time.ParseDuration DURATION +aliases: [/functions/time.parseduration] --- `time.ParseDuration` parses a duration string into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. diff --git a/content/en/functions/transform/CanHighlight.md b/content/en/functions/transform/CanHighlight.md new file mode 100644 index 000000000..eabef933b --- /dev/null +++ b/content/en/functions/transform/CanHighlight.md @@ -0,0 +1,22 @@ +--- +title: transform.CanHighlight +description: Reports whether the given code language is supported by the Chroma highlighter. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: bool + signatures: [transform.CanHighlight LANGUAGE] +relatedFunctions: + - transform.CanHighlight + - transform.Highlight + - transform.HighlightCodeBlock +--- + +```go-html-template +{{ transform.CanHighlight "go" }} → true +{{ transform.CanHighlight "klingon" }} → false +``` diff --git a/content/en/functions/emojify.md b/content/en/functions/transform/Emojify.md similarity index 81% rename from content/en/functions/emojify.md rename to content/en/functions/transform/Emojify.md index e1753cb20..324c41851 100644 --- a/content/en/functions/emojify.md +++ b/content/en/functions/transform/Emojify.md @@ -1,16 +1,19 @@ --- -title: emojify +title: transform.Emojify +linkTitle: emojify description: Runs a string through the Emoji emoticons processor. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] +function: + aliases: [emojify] + returnType: template.HTML + signatures: [transform.Emojify INPUT] namespace: transform -relatedFuncs: [] -signature: - - transform.Emojify INPUT - - emojify INPUT +relatedFunctions: [] +aliases: [/functions/emojify] --- `emojify` runs a passed string through the Emoji emoticons processor. diff --git a/content/en/functions/htmlEscape.md b/content/en/functions/transform/HTMLEscape.md similarity index 68% rename from content/en/functions/htmlEscape.md rename to content/en/functions/transform/HTMLEscape.md index cc7648068..62249367b 100644 --- a/content/en/functions/htmlEscape.md +++ b/content/en/functions/transform/HTMLEscape.md @@ -1,18 +1,20 @@ --- -title: htmlEscape +title: transform.HTMLEscape +linkTitle: htmlEscape description: Returns the given string with the reserved HTML codes escaped. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: transform -relatedFuncs: +function: + aliases: [htmlEscape] + returnType: string + signatures: [transform.HTMLEscape INPUT] +relatedFunctions: - transform.HTMLEscape - transform.HTMLUnescape -signature: - - transform.HTMLEscape INPUT - - htmlEscape INPUT +aliases: [/functions/htmlescape] --- In the result `&` becomes `&` and so on. It escapes only: `<`, `>`, `&`, `'` and `"`. diff --git a/content/en/functions/htmlUnescape.md b/content/en/functions/transform/HTMLUnescape.md similarity index 69% rename from content/en/functions/htmlUnescape.md rename to content/en/functions/transform/HTMLUnescape.md index c59248444..c0774232f 100644 --- a/content/en/functions/htmlUnescape.md +++ b/content/en/functions/transform/HTMLUnescape.md @@ -1,22 +1,22 @@ --- -title: htmlUnescape +title: transform.HTMLUnescape +linkTitle: htmlUnescape description: Returns the given string with HTML escape codes un-escaped. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] -namespace: transform -relatedFuncs: +function: + aliases: [htmlUnescape] + returnType: string + signatures: [transform.HTMLUnescape INPUT] +relatedFunctions: - transform.HTMLEscape - transform.HTMLUnescape -signature: - - transform.HTMLUnescape INPUT - - htmlUnescape INPUT +aliases: [/functions/htmlunescape] --- -`htmlUnescape` returns the given string with HTML escape codes un-escaped. - Remember to pass the output of this to `safeHTML` if fully un-escaped characters are desired. Otherwise, the output will be escaped again as normal. ```go-html-template diff --git a/content/en/functions/highlight.md b/content/en/functions/transform/Highlight.md similarity index 92% rename from content/en/functions/highlight.md rename to content/en/functions/transform/Highlight.md index 0d0fbd98a..93043b4a1 100644 --- a/content/en/functions/highlight.md +++ b/content/en/functions/transform/Highlight.md @@ -1,16 +1,22 @@ --- -title: highlight +title: transform.Highlight +linkTitle: highlight description: Renders code with a syntax highlighter. categories: [functions] +keywords: [] menu: docs: parent: functions -keywords: [] +function: + aliases: [highlight] + returnType: template.HTML + signatures: ['transform.Highlight INPUT LANG [OPTIONS]'] namespace: transform -relatedFuncs: [] -signature: - - transform.Highlight INPUT LANG [OPTIONS] - - highlight INPUT LANG [OPTIONS] +relatedFunctions: + - transform.CanHighlight + - transform.Highlight + - transform.HighlightCodeBlock +aliases: [/functions/highlight] toc: true --- diff --git a/content/en/functions/transform/HighlightCodeBlock.md b/content/en/functions/transform/HighlightCodeBlock.md new file mode 100644 index 000000000..fa7045641 --- /dev/null +++ b/content/en/functions/transform/HighlightCodeBlock.md @@ -0,0 +1,43 @@ +--- +title: transform.HighlightCodeBlock +description: Highlights code received in context within a code block render hook. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: highlight.HighlightResult + signatures: ['transform.HighlightCodeBlock CONTEXT [OPTIONS]'] +relatedFunctions: + - transform.CanHighlight + - transform.Highlight + - transform.HighlightCodeBlock +--- + +This function is only useful within a code block render hook. + +Given the context passed into a code block render hook, `transform.HighlightCodeBlock` returns a `HighlightResult` object with two methods. + +.Wrapped +: (`template.HTML`) Returns highlighted code wrapped in `
`, `
`, and `` elements. This is identical to the value returned by the transform.Highlight function.
+
+.Inner
+: (`template.HTML`) Returns highlighted code without any wrapping elements, allowing you to create your own wrapper.
+
+
+```go-html-template
+{{ $result := transform.HighlightCodeBlock . }}
+{{ $result.Wrapped }}
+```
+
+To override the default [highlighting options]:
+
+```go-html-template
+{{ $options := merge .Options (dict "linenos" true) }}
+{{ $result := transform.HighlightCodeBlock . $options }}
+{{ $result.Wrapped }}
+```
+
+[highlighting options]: /functions/transform/highlight/#options
diff --git a/content/en/functions/markdownify.md b/content/en/functions/transform/Markdownify.md
similarity index 81%
rename from content/en/functions/markdownify.md
rename to content/en/functions/transform/Markdownify.md
index 103d1703f..b0be902ce 100644
--- a/content/en/functions/markdownify.md
+++ b/content/en/functions/transform/Markdownify.md
@@ -1,16 +1,18 @@
 ---
-title: markdownify
+title: transform.Markdownify
+linkTitle: markdownify
 description: Renders markdown to HTML.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: transform
-relatedFuncs: []
-signature:
-  - transform.Markdownify INPUT
-  - markdownify INPUT
+function:
+  aliases: [markdownify]
+  returnType: template.HTML
+  signatures: [transform.Markdownify INPUT]
+relatedFunctions: []
+aliases: [/functions/markdownify]
 ---
 
 ```go-html-template
diff --git a/content/en/functions/plainify.md b/content/en/functions/transform/Plainify.md
similarity index 62%
rename from content/en/functions/plainify.md
rename to content/en/functions/transform/Plainify.md
index 17f67b692..163233d4a 100644
--- a/content/en/functions/plainify.md
+++ b/content/en/functions/transform/Plainify.md
@@ -1,16 +1,18 @@
 ---
-title: plainify
+title: transform.Plainify
+linkTitle: plainify
 description: Returns a string with all HTML tags removed.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: transform
-relatedFuncs: []
-signature:
-  - transform.Plainify
-  - plainify INPUT
+function:
+  aliases: [plainify]
+  returnType: string
+  signatures: [transform.Plainify INPUT]
+relatedFunctions: []
+aliases: [/functions/plainify]
 ---
 
 ```go-html-template
diff --git a/content/en/functions/transform.Remarshal.md b/content/en/functions/transform/Remarshal.md
similarity index 91%
rename from content/en/functions/transform.Remarshal.md
rename to content/en/functions/transform/Remarshal.md
index f961a35cd..8f6e58247 100644
--- a/content/en/functions/transform.Remarshal.md
+++ b/content/en/functions/transform/Remarshal.md
@@ -2,17 +2,19 @@
 title: transform.Remarshal
 description: Marshals a string of serialized data, or a map, into a string of serialized data in the specified format.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: transform
-relatedFuncs:
+function:
+  aliases: []
+  returnType: string
+  signatures: [transform.Remarshal FORMAT INPUT]
+relatedFunctions:
   - encoding.Jsonify
   - transform.Remarshal
   - transform.Unmarshal
-signature:
-  - transform.Remarshal FORMAT INPUT
+aliases: [/functions/transform.remarshal]
 ---
 
 The FORMAT must be one of `json`, `toml`, `yaml`, or `xml`. If the INPUT is a string of serialized data, it must be valid JSON, TOML, YAML, or XML.
diff --git a/content/en/functions/transform.Unmarshal.md b/content/en/functions/transform/Unmarshal.md
similarity index 90%
rename from content/en/functions/transform.Unmarshal.md
rename to content/en/functions/transform/Unmarshal.md
index f976b2f3d..ab32d13de 100644
--- a/content/en/functions/transform.Unmarshal.md
+++ b/content/en/functions/transform/Unmarshal.md
@@ -2,18 +2,21 @@
 title: transform.Unmarshal
 description: Parses the input and converts it into a map or an array. Supported formats are JSON, TOML, YAML, XML and CSV.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: transform
-relatedFuncs:
+function:
+  aliases: [unmarshal]
+  returnType: any
+  signatures:
+    - RESOURCE or STRING | transform.Unmarshal [OPTIONS]
+    - RESOURCE or STRING | unmarshal [OPTIONS]
+relatedFunctions:
   - encoding.Jsonify
   - transform.Remarshal
   - transform.Unmarshal
-signature:
-  - RESOURCE or STRING | transform.Unmarshal [OPTIONS]
-  - RESOURCE or STRING | unmarshal [OPTIONS]
+aliases: [/functions/transform.unmarshal]
 ---
 
 The function accepts either a `Resource` created in [Hugo Pipes](/hugo-pipes/) or via [Page Bundles](/content-management/page-bundles/), or simply a string. The two examples below will produce the same map:
diff --git a/content/en/functions/truncate.md b/content/en/functions/truncate.md
deleted file mode 100644
index 8b2121180..000000000
--- a/content/en/functions/truncate.md
+++ /dev/null
@@ -1,24 +0,0 @@
----
-title: truncate
-description: Truncates a text to a max length without cutting words or leaving unclosed HTML tags.
-categories: [functions]
-menu:
-  docs:
-    parent: functions
-keywords: []
-namespace: strings
-relatedFuncs: []
-signature:
-  - strings.Truncate SIZE [ELLIPSIS] INPUT
-  - truncate SIZE [ELLIPSIS] INPUT
----
-
-Since Go templates are HTML-aware, `truncate` will intelligently handle normal strings vs HTML strings:
-
-```go-html-template
-{{ "Keep my HTML" | safeHTML | truncate 10 }}` → Keep my …`
-```
-
-{{% note %}}
-If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML` template function](/functions/safehtml) before sending the value to truncate. Otherwise, the HTML tags will be escaped when passed through the `truncate` function.
-{{% /note %}}
diff --git a/content/en/functions/unix.md b/content/en/functions/unix.md
deleted file mode 100644
index 0d1e72700..000000000
--- a/content/en/functions/unix.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: .Unix
-description: Converts a time.Time value to the number of seconds elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970.
-categories: [functions]
-menu:
-  docs:
-    parent: functions
-namespace:
-relatedFuncs: []
-signature: 
-  - .Unix
-  - .UnixMilli
-  - .UnixMicro
-  - .UnixNano
----
-
-The `Milli`, `Micro`, and `Nano` variants return the number of milliseconds, microseconds, and nanoseconds (respectively) elapsed since the Unix epoch.
-
-```go-html-template
-.Date.Unix        --> 1637259694
-.ExpiryDate.Unix  --> 1672559999
-.Lastmod.Unix     --> 1637361786
-.PublishDate.Unix --> 1637421261
-
-("1970-01-01T00:00:00-00:00" | time.AsTime).Unix --> 0
-("1970-01-01T00:00:42-00:00" | time.AsTime).Unix --> 42
-("1970-04-11T01:48:29-08:00" | time.AsTime).Unix --> 8675309
-("2026-05-02T20:09:31-07:00" | time.AsTime).Unix --> 1777777771
-
-now.Unix      --> 1637447841
-now.UnixMilli --> 1637447841347
-now.UnixMicro --> 1637447841347378
-now.UnixNano  --> 1637447841347378799
-```
diff --git a/content/en/functions/abslangurl.md b/content/en/functions/urls/AbsLangURL.md
similarity index 92%
rename from content/en/functions/abslangurl.md
rename to content/en/functions/urls/AbsLangURL.md
index d2d129c76..ad73bbff0 100644
--- a/content/en/functions/abslangurl.md
+++ b/content/en/functions/urls/AbsLangURL.md
@@ -1,20 +1,22 @@
 ---
-title: absLangURL
+title: urls.AbsLangURL
+linkTitle: absLangURL
 description: Returns an absolute URL with a language prefix, if any.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [absLangURL]
+  returnType: template.HTML
+  signatures: [urls.AbsLangURL INPUT]
+relatedFunctions:
   - urls.AbsLangURL
   - urls.AbsURL 
   - urls.RelLangURL
   - urls.RelURL
-signature:
-  - urls.AbsLangURL INPUT
-  - absLangURL INPUT
+aliases: [/functions/abslangurl]
 ---
 
 Use this function with both monolingual and multilingual configurations. The URL returned by this function depends on:
diff --git a/content/en/functions/absurl.md b/content/en/functions/urls/AbsURL.md
similarity index 89%
rename from content/en/functions/absurl.md
rename to content/en/functions/urls/AbsURL.md
index cac1a8e77..bb6816f57 100644
--- a/content/en/functions/absurl.md
+++ b/content/en/functions/urls/AbsURL.md
@@ -1,20 +1,22 @@
 ---
-title: absURL
+title: urls.AbsURL 
+linkTitle: absURL
 description: Returns an absolute URL.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [absURL]
+  returnType: template.html
+  signatures: [urls.AbsURL INPUT]
+relatedFunctions:
   - urls.AbsLangURL
   - urls.AbsURL 
   - urls.RelLangURL
   - urls.RelURL
-signature: 
-  - urls.AbsURL INPUT
-  - absURL INPUT
+aliases: [/functions/absurl]
 ---
 
 With multilingual configurations, use the [`absLangURL`] function instead.  The URL returned by this function depends on:
@@ -66,4 +68,4 @@ With `baseURL = https://example.org/docs/`
 The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
 {{% /note %}}
 
-[`absLangURL`]: /functions/abslangurl/
+[`absLangURL`]: /functions/urls/abslangurl/
diff --git a/content/en/functions/anchorize.md b/content/en/functions/urls/Anchorize.md
similarity index 85%
rename from content/en/functions/anchorize.md
rename to content/en/functions/urls/Anchorize.md
index 1248c0b25..15efe9a5e 100644
--- a/content/en/functions/anchorize.md
+++ b/content/en/functions/urls/Anchorize.md
@@ -1,18 +1,20 @@
 ---
-title: anchorize
+title: urls.Anchorize
+linkTitle: anchorize
 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]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [anchorize]
+  returnType: string
+  signatures: [urls.Anchorize INPUT]
+relatedFunctions:
   - urls.Anchorize
   - urls.URLize
-signature:
-  - urls.Anchorize INPUT
-  - anchorize INPUT
+aliases: [/functions/anchorize]
 ---
 
 If [Goldmark](/getting-started/configuration-markup#goldmark) is set as `defaultMarkdownHandler`, the sanitizing logic adheres to the setting [`markup.goldmark.parser.autoHeadingIDType`](/getting-started/configuration-markup#goldmark).
diff --git a/content/en/functions/urls.JoinPath.md b/content/en/functions/urls/JoinPath.md
similarity index 80%
rename from content/en/functions/urls.JoinPath.md
rename to content/en/functions/urls/JoinPath.md
index caf361c92..41adf7ee7 100644
--- a/content/en/functions/urls.JoinPath.md
+++ b/content/en/functions/urls/JoinPath.md
@@ -2,16 +2,18 @@
 title: urls.JoinPath
 description: Joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. If the argument list is empty, JoinPath returns an empty string.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: []
+  returnType: string
+  signatures: [urls.JoinPath ELEMENT...]
+relatedFunctions:
   - path.Join
   - urls.JoinPath
-signature: 
-  - urls.JoinPath ELEMENT...
+aliases: [/functions/urls.joinpath]
 ---
 
 ```go-html-template
@@ -27,4 +29,4 @@ signature:
 
 Unlike the [`path.Join`] function, `urls.JoinPath` retains consecutive leading slashes.
 
-[`path.Join`]: /functions/path.join/
+[`path.Join`]: /functions/path/join
diff --git a/content/en/functions/urls.Parse.md b/content/en/functions/urls/Parse.md
similarity index 87%
rename from content/en/functions/urls.Parse.md
rename to content/en/functions/urls/Parse.md
index 7358bfae0..17c924d51 100644
--- a/content/en/functions/urls.Parse.md
+++ b/content/en/functions/urls/Parse.md
@@ -2,14 +2,16 @@
 title: urls.Parse
 description: Parses a URL into a URL structure.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs: []
-signature: 
-  - urls.Parse URL
+function:
+  aliases: []
+  returnType: URL
+  signatures: [urls.Parse URL]
+relatedFunctions: []
+aliases: [/functions/urls.parse]
 ---
 
 The `urls.Parse` function parses a URL into a [URL structure](https://godoc.org/net/url#URL). The URL may be relative (a path, without a host) or absolute (starting with a [scheme]). Hugo throws an error when parsing an invalid URL.
diff --git a/content/en/functions/ref.md b/content/en/functions/urls/Ref.md
similarity index 90%
rename from content/en/functions/ref.md
rename to content/en/functions/urls/Ref.md
index b9e8c202e..908fd6ca8 100644
--- a/content/en/functions/ref.md
+++ b/content/en/functions/urls/Ref.md
@@ -1,18 +1,20 @@
 ---
-title: ref
+title: urls.Ref
+linkTitle: ref
 description: Returns the absolute permalink to a page.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [ref]
+  returnType: template.HTML
+  signatures: [urls.Ref . PAGE]
+relatedFunctions:
   - urls.Ref
   - urls.RelRef
-signature:
-  - urls.Ref . PAGE
-  - ref . PAGE
+aliases: [/functions/ref]
 ---
 
 This function takes two arguments:
diff --git a/content/en/functions/relLangURL.md b/content/en/functions/urls/RelLangURL.md
similarity index 91%
rename from content/en/functions/relLangURL.md
rename to content/en/functions/urls/RelLangURL.md
index 6d0a37747..b8850c71d 100644
--- a/content/en/functions/relLangURL.md
+++ b/content/en/functions/urls/RelLangURL.md
@@ -1,20 +1,22 @@
 ---
-title: relLangURL
+title: urls.RelLangURL
+linkTitle: relLangURL
 description: Returns a relative URL with a language prefix, if any.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [relLangURL]
+  returnType: template.HTML
+  signatures: [urls.RelLangURL INPUT]
+relatedFunctions:
   - urls.AbsLangURL
   - urls.AbsURL 
   - urls.RelLangURL
   - urls.RelURL
-signature:
-  - urls.RelLangURL INPUT
-  - relLangURL INPUT
+aliases: [/functions/rellangurl]
 ---
 
 Use this function with both monolingual and multilingual configurations. The URL returned by this function depends on:
diff --git a/content/en/functions/relref.md b/content/en/functions/urls/RelRef.md
similarity index 91%
rename from content/en/functions/relref.md
rename to content/en/functions/urls/RelRef.md
index 1d91c1444..1ff213b70 100644
--- a/content/en/functions/relref.md
+++ b/content/en/functions/urls/RelRef.md
@@ -1,18 +1,20 @@
 ---
-title: relref
+title: urls.RelRef
+linkTitle: relref
 description: Returns the relative permalink to a page.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [relref]
+  returnType: template.HTML
+  signatures: [urls.RelRef . PAGE]
+relatedFunctions:
   - urls.Ref
   - urls.RelRef
-signature:
-  - urls.RelRef . PAGE
-  - relref . PAGE
+aliases: [/functions/relref]
 ---
 
 This function takes two arguments:
diff --git a/content/en/functions/relurl.md b/content/en/functions/urls/RelURL.md
similarity index 88%
rename from content/en/functions/relurl.md
rename to content/en/functions/urls/RelURL.md
index ea3e51141..fa1f9af73 100644
--- a/content/en/functions/relurl.md
+++ b/content/en/functions/urls/RelURL.md
@@ -1,20 +1,22 @@
 ---
-title: relURL
+title: urls.RelURL
+linkTitle: relURL
 description: Returns a relative URL.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [relURL]
+  returnType: template.HTML
+  signatures: [urls.RelURL INPUT]
+relatedFunctions:
   - urls.AbsLangURL
   - urls.AbsURL 
   - urls.RelLangURL
   - urls.RelURL
-signature:
-  - urls.RelURL INPUT
-  - relURL INPUT
+aliases: [/functions/relurl]
 ---
 
 With multilingual configurations, use the [`relLangURL`] function instead. The URL returned by this function depends on:
@@ -66,4 +68,4 @@ With `baseURL = https://example.org/docs/`
 The last three examples are not desirable in most situations. As a best practice, never include a leading slash when using this function.
 {{% /note %}}
 
-[`relLangURL`]: /functions/rellangurl/
+[`relLangURL`]: /functions/urls/rellangurl/
diff --git a/content/en/functions/urlize.md b/content/en/functions/urls/URLize.md
similarity index 89%
rename from content/en/functions/urlize.md
rename to content/en/functions/urls/URLize.md
index 820d43f99..3c80a92f8 100644
--- a/content/en/functions/urlize.md
+++ b/content/en/functions/urls/URLize.md
@@ -1,18 +1,20 @@
 ---
-title: urlize
+title: urls.URLize
+linkTitle: urlize
 description: Takes a string, sanitizes it for usage in URLs, and converts spaces to hyphens.
 categories: [functions]
+keywords: []
 menu:
   docs:
     parent: functions
-keywords: []
-namespace: urls
-relatedFuncs:
+function:
+  aliases: [urlize]
+  returnType: string
+  signatures: [urls.URLize INPUT]
+relatedFunctions:
   - urls.Anchorize
   - urls.URLize
-signature:
-  - urls.URLize INPUT
-  - urlize INPUT
+aliases: [/functions/urlize]
 ---
 
 The following examples pull from a content file with the following front matter:
diff --git a/content/en/getting-started/configuration-markup.md b/content/en/getting-started/configuration-markup.md
index dca2b3c52..ae7241dc5 100644
--- a/content/en/getting-started/configuration-markup.md
+++ b/content/en/getting-started/configuration-markup.md
@@ -80,7 +80,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.
+: 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/urls/anchorize) template func.
 
 ## Highlight
 
diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md
index d210765ab..e72bb8d3b 100644
--- a/content/en/getting-started/configuration.md
+++ b/content/en/getting-started/configuration.md
@@ -400,7 +400,7 @@ URL to be used as a placeholder when a page reference cannot be found in `ref` o
 Removes [non-spacing marks](https://www.compart.com/en/unicode/category/Mn) from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character) in content paths.
 
 ```text
-content/post/hügó.md --> https://example.org/post/hugo/
+content/post/hügó.md → https://example.org/post/hugo/
 ```
 
 ### rssLimit
@@ -449,7 +449,7 @@ Timeout for generating page contents, specified as a [duration](https://pkg.go.d
 
 ### timeZone
 
-The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time` function](/functions/time/). The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
+The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time`] function. The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
 
 ### title
 
@@ -527,8 +527,6 @@ useResourceCacheWhen
 
 The `build.cachebusters` configuration option was added to support development using Tailwind 3.x's JIT compiler where a `build` configuration may look like this:
 
-
-
 {{< code-toggle file="hugo" >}}
 [build]
   [build.buildStats]
@@ -616,7 +614,7 @@ status = 404
 
 ## Configure title case
 
-Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo.
+Set `titleCaseStyle` to specify the title style used by the [title](/functions/strings/title) template function and the automatic section titles in Hugo.
 
 Can be one of:
 
@@ -684,10 +682,6 @@ To set configuration parameters, prefix the name with `HUGO_PARAMS_`
 
 If you are using snake_cased variable names, the above will not work. Hugo determines the delimiter to use by the first character after `HUGO`. This allows you to define environment variables on the form `HUGOxPARAMSxAPI_KEY=abcdefgh`, using any [allowed](https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names#:~:text=So%20names%20may%20contain%20any,not%20begin%20with%20a%20digit.) delimiter.
 
-{{< todo >}}
-Test and document setting parameters via JSON env var.
-{{< /todo >}}
-
 ## Ignore content and data files when rendering
 
 **Note:** This works, but we recommend you use the newer and more powerful [includeFiles and excludeFiles](/hugo-modules/configuration/#module-configuration-mounts) mount options.
@@ -799,7 +793,7 @@ dir
 
 [`.Site.Params`]: /variables/site/
 [directory structure]: /getting-started/directory-structure
-[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation"
+[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
 [lookup order]: /templates/lookup-order/
 [Output Formats]: /templates/output-formats/
 [templates]: /templates/
@@ -821,3 +815,6 @@ If this is not set, Hugo will use, in order of preference:
 1. In a  `hugo_cache_$USER` directory below the OS temp dir.
 
 If you want to know the current value of `cacheDir`, you can run `hugo config`, e.g: `hugo config | grep cachedir`.
+
+
+[`time`]: /functions/time/astime
diff --git a/content/en/getting-started/glossary.md b/content/en/getting-started/glossary.md
index 404732a23..c15af5170 100644
--- a/content/en/getting-started/glossary.md
+++ b/content/en/getting-started/glossary.md
@@ -254,7 +254,7 @@ A packaged combination of [archetypes](#archetype), assets, content, data, [temp
 
 ### token
 
-An identifier within a format string, beginning with a colon and replaced with a value when rendered. For example, use tokens in format strings for both [permalinks](/content-management/urls/#permalinks) and [dates](/functions/dateformat/#datetime-formatting-layouts).
+An identifier within a format string, beginning with a colon and replaced with a value when rendered. For example, use tokens in format strings for both [permalinks](/content-management/urls/#permalinks) and [dates](/functions/time/format/#localization).
 
 
 ### type
diff --git a/content/en/hosting-and-deployment/hosting-on-firebase.md b/content/en/hosting-and-deployment/hosting-on-firebase.md
index 3b1ba9dcd..c58f4b752 100644
--- a/content/en/hosting-and-deployment/hosting-on-firebase.md
+++ b/content/en/hosting-and-deployment/hosting-on-firebase.md
@@ -47,26 +47,26 @@ From here:
 
 In new versions of Firebase, some other questions apply:
 
-6. Set up automatic builds and deploys with GitHub? 
+6. Set up automatic builds and deploys with GitHub?
 
 Here you will be redirected to login in your GitHub account to get permissions. Confirm.
 
-7. For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) 
+7. For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)
 
 Include the repository you will use in the format above (Account/Repo)
 Firebase script with retrieve credentials, create a service account you can later manage in your GitHub settings.
 
-8. Set up the workflow to run a build script before every deploy? 
+8. Set up the workflow to run a build script before every deploy?
 
 Here is your opportunity to include some commands before you run the deploy.
 
-9. Set up automatic deployment to your site's live channel when a PR is merged? 
+9. Set up automatic deployment to your site's live channel when a PR is merged?
 
 You can let in the default option (main)
 
 After that Firebase has been set in your project with CI/CD. After that run:
 
-```
+```sh
 hugo && firebase deploy
 ```
 
diff --git a/content/en/hugo-pipes/babel.md b/content/en/hugo-pipes/babel.md
index 222b5116b..44b4e670e 100755
--- a/content/en/hugo-pipes/babel.md
+++ b/content/en/hugo-pipes/babel.md
@@ -8,7 +8,7 @@ menu:
     parent: hugo-pipes
     weight: 70
 weight: 70
-signature: ["resources.Babel RESOURCE [OPTIONS]", "babel RESOURCE [OPTIONS]"]
+signatures: ["resources.Babel RESOURCE [OPTIONS]", "babel RESOURCE [OPTIONS]"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/bundling.md b/content/en/hugo-pipes/bundling.md
index 8b9899432..f3ff42f9c 100755
--- a/content/en/hugo-pipes/bundling.md
+++ b/content/en/hugo-pipes/bundling.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 90
 weight: 90
-signature: ["resources.Concat TARGET_PATH SLICE_RESOURCES"]
+signatures: ["resources.Concat TARGET_PATH SLICE_RESOURCES"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/fingerprint.md b/content/en/hugo-pipes/fingerprint.md
index bdabbe029..c492d4c70 100755
--- a/content/en/hugo-pipes/fingerprint.md
+++ b/content/en/hugo-pipes/fingerprint.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 100
 weight: 100
-signature: ["resources.Fingerprint RESOURCE [ALGORITHM]", "fingerprint RESOURCE [ALGORITHM]"]
+signatures: ["resources.Fingerprint RESOURCE [ALGORITHM]", "fingerprint RESOURCE [ALGORITHM]"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/js.md b/content/en/hugo-pipes/js.md
index 86c1564cf..ecf6dc33f 100644
--- a/content/en/hugo-pipes/js.md
+++ b/content/en/hugo-pipes/js.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 60
 weight: 60
-signature: ["js.Build RESOURCE [OPTIONS]"]
+signatures: ["js.Build RESOURCE [OPTIONS]"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/minification.md b/content/en/hugo-pipes/minification.md
index a32ef6e6f..74ddfaa89 100755
--- a/content/en/hugo-pipes/minification.md
+++ b/content/en/hugo-pipes/minification.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 80
 weight: 80
-signature: ["resources.Minify RESOURCE", "minify RESOURCE"]
+signatures: ["resources.Minify RESOURCE", "minify RESOURCE"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/postcss.md b/content/en/hugo-pipes/postcss.md
index 4e969caf2..2a08c7ad4 100755
--- a/content/en/hugo-pipes/postcss.md
+++ b/content/en/hugo-pipes/postcss.md
@@ -9,7 +9,7 @@ menu:
     weight: 40
 toc: true
 weight: 40
-signature: ["resources.PostCSS RESOURCE [OPTIONS]", "postCSS RESOURCE [OPTIONS]"]
+signatures: ["resources.PostCSS RESOURCE [OPTIONS]", "postCSS RESOURCE [OPTIONS]"]
 ---
 
 ## Setup
diff --git a/content/en/hugo-pipes/postprocess.md b/content/en/hugo-pipes/postprocess.md
index 3b7d5c610..4b3cb8ad4 100755
--- a/content/en/hugo-pipes/postprocess.md
+++ b/content/en/hugo-pipes/postprocess.md
@@ -8,7 +8,7 @@ menu:
     parent: hugo-pipes
     weight: 50
 weight: 50
-signature: ["resources.PostProcess RESOURCE"]
+signatures: ["resources.PostProcess RESOURCE"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/resource-from-string.md b/content/en/hugo-pipes/resource-from-string.md
index f3f0cda4f..fa472715c 100755
--- a/content/en/hugo-pipes/resource-from-string.md
+++ b/content/en/hugo-pipes/resource-from-string.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 110
 weight: 110
-signature: ["resources.FromString TARGET_PATH CONTENT"]
+signatures: ["resources.FromString TARGET_PATH CONTENT"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/resource-from-template.md b/content/en/hugo-pipes/resource-from-template.md
index 4f34817c0..c1c4cb316 100755
--- a/content/en/hugo-pipes/resource-from-template.md
+++ b/content/en/hugo-pipes/resource-from-template.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 120
 weight: 120
-signature: ["resources.ExecuteAsTemplate TARGET_PATH CONTEXT RESOURCE"]
+signatures: ["resources.ExecuteAsTemplate TARGET_PATH CONTEXT RESOURCE"]
 ---
 
 ## Usage
diff --git a/content/en/hugo-pipes/transpile-sass-to-css.md b/content/en/hugo-pipes/transpile-sass-to-css.md
index bf3d136f1..b09cc165b 100644
--- a/content/en/hugo-pipes/transpile-sass-to-css.md
+++ b/content/en/hugo-pipes/transpile-sass-to-css.md
@@ -9,7 +9,7 @@ menu:
     parent: hugo-pipes
     weight: 30
 weight: 30
-signature: ["resources.ToCSS RESOURCE [OPTIONS]", "toCSS RESOURCE [OPTIONS]"]
+signatures: ["resources.ToCSS RESOURCE [OPTIONS]", "toCSS RESOURCE [OPTIONS]"]
 toc: true
 aliases: [/hugo-pipes/transform-to-css/]
 ---
diff --git a/content/en/installation/common/01-editions.md b/content/en/installation/_common/01-editions.md
similarity index 100%
rename from content/en/installation/common/01-editions.md
rename to content/en/installation/_common/01-editions.md
diff --git a/content/en/installation/common/02-prerequisites.md b/content/en/installation/_common/02-prerequisites.md
similarity index 100%
rename from content/en/installation/common/02-prerequisites.md
rename to content/en/installation/_common/02-prerequisites.md
diff --git a/content/en/installation/common/03-prebuilt-binaries.md b/content/en/installation/_common/03-prebuilt-binaries.md
similarity index 100%
rename from content/en/installation/common/03-prebuilt-binaries.md
rename to content/en/installation/_common/03-prebuilt-binaries.md
diff --git a/content/en/installation/common/04-docker.md b/content/en/installation/_common/04-docker.md
similarity index 100%
rename from content/en/installation/common/04-docker.md
rename to content/en/installation/_common/04-docker.md
diff --git a/content/en/installation/common/05-build-from-source.md b/content/en/installation/_common/05-build-from-source.md
similarity index 100%
rename from content/en/installation/common/05-build-from-source.md
rename to content/en/installation/_common/05-build-from-source.md
diff --git a/content/en/installation/common/homebrew.md b/content/en/installation/_common/homebrew.md
similarity index 100%
rename from content/en/installation/common/homebrew.md
rename to content/en/installation/_common/homebrew.md
diff --git a/content/en/installation/common/index.md b/content/en/installation/_common/index.md
similarity index 100%
rename from content/en/installation/common/index.md
rename to content/en/installation/_common/index.md
diff --git a/content/en/installation/bsd.md b/content/en/installation/bsd.md
index 5fbc4bfad..e767b5c08 100644
--- a/content/en/installation/bsd.md
+++ b/content/en/installation/bsd.md
@@ -9,11 +9,11 @@ menu:
 toc: true
 weight: 50
 ---
-{{% readfile file="/installation/common/01-editions.md" %}}
+{{% readfile file="/installation/_common/01-editions.md" %}}
 
-{{% readfile file="/installation/common/02-prerequisites.md" %}}
+{{% readfile file="/installation/_common/02-prerequisites.md" %}}
 
-{{% readfile file="/installation/common/03-prebuilt-binaries.md" %}}
+{{% readfile file="/installation/_common/03-prebuilt-binaries.md" %}}
 
 ## Repository packages
 
@@ -61,7 +61,7 @@ doas pkg_add hugo
 
 [OpenBSD]: https://www.openbsd.org/
 
-{{% readfile file="/installation/common/05-build-from-source.md" %}}
+{{% readfile file="/installation/_common/05-build-from-source.md" %}}
 
 ## Comparison
 
diff --git a/content/en/installation/linux.md b/content/en/installation/linux.md
index 4056b987a..aec811cbd 100644
--- a/content/en/installation/linux.md
+++ b/content/en/installation/linux.md
@@ -9,11 +9,11 @@ menu:
 toc: true
 weight: 30
 ---
-{{% readfile file="/installation/common/01-editions.md" %}}
+{{% readfile file="/installation/_common/01-editions.md" %}}
 
-{{% readfile file="/installation/common/02-prerequisites.md" %}}
+{{% readfile file="/installation/_common/02-prerequisites.md" %}}
 
-{{% readfile file="/installation/common/03-prebuilt-binaries.md" %}}
+{{% readfile file="/installation/_common/03-prebuilt-binaries.md" %}}
 
 ## Package managers
 
@@ -47,7 +47,7 @@ sudo snap disconnect hugo:ssh-keys
 [strictly confined]: https://snapcraft.io/docs/snap-confinement
 [Snap]: https://snapcraft.io/
 
-{{% readfile file="/installation/common/homebrew.md" %}}
+{{% readfile file="/installation/_common/homebrew.md" %}}
 
 ## Repository packages
 
@@ -124,9 +124,9 @@ sudo eopkg install hugo
 
 [Solus]: https://getsol.us/
 
-{{% readfile file="/installation/common/04-docker.md" %}}
+{{% readfile file="/installation/_common/04-docker.md" %}}
 
-{{% readfile file="/installation/common/05-build-from-source.md" %}}
+{{% readfile file="/installation/_common/05-build-from-source.md" %}}
 
 ## Comparison
 
diff --git a/content/en/installation/macos.md b/content/en/installation/macos.md
index 9d10642de..d1b77d853 100644
--- a/content/en/installation/macos.md
+++ b/content/en/installation/macos.md
@@ -9,15 +9,15 @@ menu:
 toc: true
 weight: 20
 ---
-{{% readfile file="/installation/common/01-editions.md" %}}
+{{% readfile file="/installation/_common/01-editions.md" %}}
 
-{{% readfile file="/installation/common/02-prerequisites.md" %}}
+{{% readfile file="/installation/_common/02-prerequisites.md" %}}
 
-{{% readfile file="/installation/common/03-prebuilt-binaries.md" %}}
+{{% readfile file="/installation/_common/03-prebuilt-binaries.md" %}}
 
 ## Package managers
 
-{{% readfile file="/installation/common/homebrew.md" %}}
+{{% readfile file="/installation/_common/homebrew.md" %}}
 
 ### MacPorts
 
@@ -29,9 +29,9 @@ sudo port install hugo
 
 [MacPorts]: https://www.macports.org/
 
-{{% readfile file="/installation/common/04-docker.md" %}}
+{{% readfile file="/installation/_common/04-docker.md" %}}
 
-{{% readfile file="/installation/common/05-build-from-source.md" %}}
+{{% readfile file="/installation/_common/05-build-from-source.md" %}}
 
 ## Comparison
 
diff --git a/content/en/installation/windows.md b/content/en/installation/windows.md
index 92979d9f2..949e94776 100644
--- a/content/en/installation/windows.md
+++ b/content/en/installation/windows.md
@@ -9,11 +9,11 @@ menu:
 toc: true
 weight: 40
 ---
-{{% readfile file="/installation/common/01-editions.md" %}}
+{{% readfile file="/installation/_common/01-editions.md" %}}
 
-{{% readfile file="/installation/common/02-prerequisites.md" %}}
+{{% readfile file="/installation/_common/02-prerequisites.md" %}}
 
-{{% readfile file="/installation/common/03-prebuilt-binaries.md" %}}
+{{% readfile file="/installation/_common/03-prebuilt-binaries.md" %}}
 
 ## Package managers
 
@@ -47,9 +47,9 @@ winget install Hugo.Hugo.Extended
 
 [Winget]: https://learn.microsoft.com/en-us/windows/package-manager/
 
-{{% readfile file="/installation/common/04-docker.md" %}}
+{{% readfile file="/installation/_common/04-docker.md" %}}
 
-{{% readfile file="/installation/common/05-build-from-source.md" %}}
+{{% readfile file="/installation/_common/05-build-from-source.md" %}}
 
 {{% note %}}
 See these [detailed instructions](https://discourse.gohugo.io/t/41370) to install GCC on Windows.
diff --git a/content/en/readfiles/README.md b/content/en/readfiles/README.md
deleted file mode 100644
index 4b10f0e47..000000000
--- a/content/en/readfiles/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# readdirs Directory for Reusable Content
-
-Files in this directory are:
-
-1. Used in *more than one place* within the Hugo docs
-2. Used in Examples of readdir (i.e. in local file templates)
-
-These files are called using the [`readfile` shortcode (source)](../layouts/readfile.html).
-
-You can call this shortcode in the docs as follows:
-
-
-{{% readfile file="/path/to/file.txt" markdown="true" %}}
-
-
-`markdown="true"` is optional (default = `"false"`) and parses the string through the Blackfriday renderer.
diff --git a/content/en/readfiles/dateformatting.md b/content/en/readfiles/dateformatting.md
deleted file mode 100644
index e6c395151..000000000
--- a/content/en/readfiles/dateformatting.md
+++ /dev/null
@@ -1,87 +0,0 @@
-Go templates [format your dates][time] according to a single reference time:
-
-```txt
-Mon Jan 2 15:04:05 MST 2006
-```
-
-You can think of `MST` as `07`, thus making the reference format string a sequence of numbers. The following is [taken directly from the Go docs][gdex]:
-
-```txt
-Jan 2 15:04:05 2006 MST
-  1 2  3  4  5    6  -7
-```
-
-### Hugo date templating reference
-
-Each of the following examples show the reference formatting string followed by the string Hugo will output in your HTML.
-
-Note that the examples were rendered and tested in [CST] and pull from a single example date you might have in your content's front matter:
-
-```yml
-date: 2017-03-03T14:15:59-06:00
-```
-
-`.Date` (i.e. called via [page variable][pagevars])
-: **Returns**: `2017-03-03 14:15:59 -0600 CST`
-
-`"Monday, January 2, 2006"`
-: **Returns**: `Friday, March 3, 2017`
-
-`"Mon Jan 2 2006"`
-: **Returns**: `Fri Mar 3 2017`
-
-`"January 2nd"`
-: **Returns**: `March 3rd`
-
-`"January 2006"`
-: **Returns**: `March 2017`
-
-`"2006-01-02"`
-: **Returns**: `2017-03-03`
-
-`"Monday"`
-: **Returns**: `Friday`
-
-`"02 Jan 06 15:04 MST"` (RFC822)
-: **Returns**: `03 Mar 17 14:15 CST`
-
-`"02 Jan 06 15:04 -0700"` (RFC822Z)
-: **Returns**: `03 Mar 17 14:15 -0600`
-
-`"Mon, 02 Jan 2006 15:04:05 MST"` (RFC1123)
-: **Returns**: `Fri, 03 Mar 2017 14:15:59 CST`
-
-`"Mon, 02 Jan 2006 15:04:05 -0700"` (RFC339)
-: **Returns**: `Fri, 03 Mar 2017 14:15:59 -0600`
-
-### Cardinal numbers and ordinal abbreviations
-
-Spelled-out cardinal numbers (e.g. "one", "two", and "three") and ordinal abbreviations (e.g. "1st", "2nd", and "3rd") are not currently supported.
-
-To continue with the example above:
-
-```go-html-template
-{{ .Date.Format "Jan 2nd 2006" }}
-```
-
-Hugo assumes you want to append `nd` as a string to the day of the month and outputs the following:
-
-```txt
-Mar 2nd 2017
-```
-
-### Use `.Local` and `.UTC`
-
-In conjunction with the [`dateFormat` function][dateFormat], you can also convert your dates to `UTC` or to local timezones:
-
-`{{ dateFormat "02 Jan 06 15:04 MST" .Date.UTC }}`
-: **Returns**: `03 Mar 17 20:15 UTC`
-
-`{{ dateFormat "02 Jan 06 15:04 MST" .Date.Local }}`
-: **Returns**: `03 Mar 17 14:15 CST`
-
-[CST]: https://en.wikipedia.org/wiki/Central_Time_Zone
-[dateFormat]: /functions/dateformat/
-[gdex]: https://golang.org/pkg/time/#example_Time_Format
-[pagevars]: /variables/page/
-[time]: https://golang.org/pkg/time/
diff --git a/content/en/readfiles/index.md b/content/en/readfiles/index.md
deleted file mode 100644
index 3d65eaa0f..000000000
--- a/content/en/readfiles/index.md
+++ /dev/null
@@ -1,3 +0,0 @@
----
-headless: true
----
\ No newline at end of file
diff --git a/content/en/readfiles/sectionvars.md b/content/en/readfiles/sectionvars.md
deleted file mode 100644
index 45aaff1f3..000000000
--- a/content/en/readfiles/sectionvars.md
+++ /dev/null
@@ -1,23 +0,0 @@
-.CurrentSection
-: The page's current section. The value can be the page itself if it is a section or the homepage.
-
-.FirstSection
-: The page's first section below root, e.g. `/docs`, `/blog` etc.
-
-.InSection $anotherPage
-: Whether the given page is in the current section.
-
-.IsAncestor $anotherPage
-: Whether the current page is an ancestor of the given page.
-
-.IsDescendant $anotherPage
-: Whether the current page is a descendant of the given page.
-
-.Parent
-: A section's parent section or a page's section.
-
-.Section
-: The [section](/content-management/sections/) this content belongs to. **Note:** For nested sections, this is the first path element in the directory, for example, `/blog/funny/mypost/ => blog`.
-
-.Sections
-: The [sections](/content-management/sections/) below this content.
diff --git a/content/en/readfiles/testing.txt b/content/en/readfiles/testing.txt
deleted file mode 100644
index 6428710e3..000000000
--- a/content/en/readfiles/testing.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-##### Hello World!
-
-Testing one, **two**, *three*. Don't delete this sample file used in the [templates](/templates/) section of the Hugo docs.
\ No newline at end of file
diff --git a/content/en/templates/data-templates.md b/content/en/templates/data-templates.md
index 0aadbb9ae..cf835af44 100644
--- a/content/en/templates/data-templates.md
+++ b/content/en/templates/data-templates.md
@@ -20,7 +20,7 @@ Hugo supports loading data from YAML, JSON, XML, and TOML files located in the `
 
 ## The data folder
 
-The `data` folder should store additional data for Hugo to use when generating your site. 
+The `data` folder should store additional data for Hugo to use when generating your site.
 
 Data files are not for generating standalone pages. They should supplement content files by:
 
@@ -37,7 +37,7 @@ To access the data using the `site.Data.filename` notation, the file name must b
 - `x123.json` - Valid
 - `_123.json` - Valid
 
-To access the data using the [`index`](/functions/index-function/) function, the file name is irrelevant. For example:
+To access the data using the [`index`](/functions/collections/indexfunction) function, the file name is irrelevant. For example:
 
 Data file|Template code
 :--|:--
@@ -130,8 +130,7 @@ You can use the following code to render the `Short Description` in your layout:
 
Short Description of {{ .Site.Data.User0123.Name }}:

{{ index .Site.Data.User0123 "Short Description" | markdownify }}

``` -Note the use of the [`markdownify` template function][markdownify]. This will send the description through the Markdown rendering engine. - +Note the use of the [`markdownify`] function. This will send the description through the Markdown rendering engine. ## Get remote data @@ -255,10 +254,10 @@ If you change any local file and the LiveReload is triggered, Hugo will read the [config]: /getting-started/configuration/ [csv]: https://tools.ietf.org/html/rfc4180 [customize]: /hugo-modules/theme-components/ -[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" +[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf [LiveReload]: /getting-started/usage/#livereload [lookup]: /templates/lookup-order/ -[markdownify]: /functions/markdownify/ +[`markdownify`]: /functions/transform/markdownify [OAuth]: https://en.wikipedia.org/wiki/OAuth [partials]: /templates/partials/ [toml]: https://toml.io/en/latest diff --git a/content/en/templates/files.md b/content/en/templates/files.md index 7b058d531..2e82688c0 100644 --- a/content/en/templates/files.md +++ b/content/en/templates/files.md @@ -14,11 +14,11 @@ toc: true ## Traverse local files -With Hugo's [`readDir`][readDir] and [`readFile`][readFile] template functions, you can traverse your website's files on your server. +With Hugo's [`readDir`] and [`readFile`] template functions, you can traverse your website's files on your server. ## Use `readDir` -The [`readDir` function][readDir] returns an array of [`os.FileInfo`][osfileinfo]. It takes the file's `path` as a single string argument. This path can be to any directory of your website (i.e., as found on your server's file system). +The [`readDir`] function returns an array of [`os.FileInfo`] structures. It takes the file's `path` as a single string argument. This path can be to any directory of your website (i.e., as found on your server's file system). Whether the path is absolute or relative does not matter because---at least for `readDir`---the root of your website (typically `./public/`) in effect becomes both: @@ -27,7 +27,7 @@ Whether the path is absolute or relative does not matter because---at least for ## Use `readFile` -The [`readfile` function][readFile] reads a file from disk and converts it into a string to be manipulated by other Hugo functions or added as-is. `readFile` takes the file, including path, as an argument passed to the function. +The [`readfile`] function reads a file from disk and converts it into a string to be manipulated by other Hugo functions or added as-is. `readFile` takes the file, including path, as an argument passed to the function. To use the `readFile` function in your templates, make sure the path is relative to your *Hugo project's root directory*: @@ -48,10 +48,9 @@ If you are going to create [custom shortcodes](/templates/shortcode-templates/) {{% /note %}} [called directly in the Hugo docs]: https://github.com/gohugoio/hugoDocs/blob/master/content/en/templates/files.md -[osfileinfo]: https://golang.org/pkg/os/#FileInfo -[readDir]: /functions/readdir/ -[readFile]: /functions/readfile/ +[`os.FileInfo`]: https://pkg.go.dev/io/fs#FileInfo +[`readDir`]: /functions/os/readdir +[`readFile`]: /functions/os/readfile [sc]: /content-management/shortcodes/ [sct]: /templates/shortcode-templates/ [readfilesource]: https://github.com/gohugoio/hugoDocs/blob/master/layouts/shortcodes/readfile.html -[testfile]: https://github.com/gohugoio/hugoDocs/blob/master/content/en/readfiles/testing.txt diff --git a/content/en/templates/introduction.md b/content/en/templates/introduction.md index 5d60e9ed1..93666de28 100644 --- a/content/en/templates/introduction.md +++ b/content/en/templates/introduction.md @@ -301,7 +301,7 @@ Below example is "Example 1" rewritten using `if`: #### Example 4: `if` .. `else` Below example is "Example 2" rewritten using `if` .. `else`, and using -[`isset` function][isset] + `.Params` variable (different from the +[`isset`] + `.Params` variable (different from the [`.Param` **function**][param]) instead: ```go-html-template @@ -355,7 +355,7 @@ The following two examples are functionally the same: ### Example 2: `index` -The following accesses the page parameter called "disqus_url" and escapes the HTML. This example also uses the [`index` function](/functions/index-function/), which is built into Go Templates: +The following accesses the page parameter called "disqus_url" and escapes the HTML. This example also uses the [`index`] function, which is built into Go Templates: ```go-html-template {{ index .Params "disqus_url" | html }} @@ -569,7 +569,7 @@ params: sidebarrecentlimit: 5 {{< /code >}} -Within a footer layout, you might then declare a `