CodeYourFuture / CodeYourFuture/curriculum
Update shortcode to use try instead of .Err for Hugo 0.141+ compatibility
- Dominant language
- HTML
- Stars
- 76
- Forks
- 135
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 20
Description
**Describe the bug**
While I was trying to run the repo locally. I encountered the following error:
```
Error: error building site: render: failed to render pages: render of "D:/CodeYourFuture/curriculum/org-cyf-guides/content/contributing/contributors/index.md" failed: "D:\CodeYourFuture\curriculum\common-theme\layouts\_default\single.html:4:12": execute of template failed: template: single.html:4:12: executing "main" at <.Content>: error calling Content: "D:\CodeYourFuture\curriculum\org-cyf-guides\content\contributing\contributors\index.md:11:1": failed to render shortcode "contributors": failed to process shortcode: "D:\CodeYourFuture\curriculum\common-theme\layouts\shortcodes\contributors.html:13:10": execute of template failed: template: _shortcodes/contributors.html:13:10: executing "_shortcodes/contributors.html" at <.Err>: can't evaluate field Err in type resource.Resource: Resource.Err was removed in Hugo v0.141.0 and replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/
```
**What is wrong with this content?**
Hugo v0.141.0 removed support for .Err on resource.Resource types and introduced the try keyword as a replacement. The contributors.html shortcode currently uses .Err, which causes the site to break on newer Hugo versions with the following error:
**How could this be fixed?**
Refactor the shortcode to use the try pattern. This change will ensure forward compatibility with Hugo and prevent build errors for contributors using recent versions.
**Link to content**
https://gohugo.io/functions/go-template/try/
**Additional context**
I thought I would ask someone before refactoring the code.
**Who else might need to know about this?**
@SallyMcGrath @illicitonion
Contributor guide
Assessment
This issue has not been assessed yet.