CloudWithChris / hugo-creator

The Hugo Creator theme is a custom theme that I have built for the Hugo Static Site generator. It is designed for content creators (e.g. Bloggers, Podcasters and Vloggers), allowing you to worry less about your website and focus more on your content creation!
https://hugo-creator.cloudwithchris.com/
MIT License
7 stars 1 forks source link

Seeking help to fix rendering and stylesheet import errors in Hugo project #125

Closed SamGreenwood1 closed 1 year ago

SamGreenwood1 commented 1 year ago

Discussed in https://github.com/CloudWithChris/hugo-creator/discussions/124

Originally posted by **SamGreenwood1** May 11, 2023 $hugo-filecache = /tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/cloudwithchris I'm encountering two errors in my Hugo project and could use some guidance in resolving them. Here's a summary of the situation: Error during rendering: When attempting to render a page in my project, an error occurs at line 55 of the template _default/search.html. The specific error is related to the execution of $.Scratch.Add, resulting in a "reflect.Value.Type on zero Value" error. Stylesheet import error: While building the site, there is an issue with transforming the SCSS file style.main.scss. The error points to line 4 of main.scss and states that the import file bootstrap/functions cannot be found or read. Actual error messages: ``` ERROR 2023/05/11 18:41:45 failed to render pages: render of "page" failed: "$hugo-filecache/hugo-creator@v0.0.27-0.20220911012120-e40988e0ccc9/layouts/_default/search.html:55:8": execute of template failed: template: _default/search.html:55:8: executing "main" at <$.Scratch.Add>: error calling Add: reflect: call of reflect.Value.Type on zero Value ``` ``` Error: Error building site: TOCSS: failed to transform "style.main.scss" (text/x-scss): "$hugo-filecache/hugo-creator@v0.0.27-0.20220911012120-e40988e0ccc9/assets/sass/main.scss:4:1": File to import not found or unreadable: bootstrap/functions ``` If you have any experience with these errors or expertise in Hugo and SCSS, I would greatly appreciate your insights and any suggestions for resolving these issues.
chrisreddington commented 1 year ago

@SamGreenwood1 - Some quick verification questions:

  1. For the Hugo version, are you using Hugo extended, and a recent version?
  2. Have you downloaded the needed packages from npm using npm ci/npm install?

The majority of issues where I've seen this come up relate to those two (particularly that last one, given it was unable to read the bootstrap/functions component, so hints at a dependency issue)

SamGreenwood1 commented 1 year ago

Just saw this:

  1. I think so
  2. Which packages?
SamGreenwood1 commented 1 year ago

I seem to have somehow inadvertently fixed those errors, now I get this one: WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false. WARN 2023/05/27 19:29:53 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}

Error: error building site: render: failed to render pages: render of "home" failed: 
"$hugo-filecache/hugo-creator@v0.0.27-0.20220911012120-e40988e0ccc9/layouts/index.html:66:43": 
execute of template failed: template: index.html:66:43: executing "top" at <first 3>:
error calling first: both limit and seq must be provided
SamGreenwood1 commented 1 year ago

I am still having trouble with it. I checked, and index.html matches the repo. I also checked npm, and everything in package.json seems to be installed. To be clear, the rest of the site renders fine, it's just an issue with index.html.

Also, does the theme support the ability to mark episodes "upcoming"?

SamGreenwood1 commented 1 year ago

@chrisreddington Still waiting for help, I've definitely tracked the issue to index.html.

chrisreddington commented 1 year ago

Sorry for the delay. Between holiday and other commitments, I'm only just getting a chance to check back in. I'm wondering if there's some logic on the homepage where I'm expecting certain content to be there, and perhaps there's a scenario I haven't accounted for.

Do you have a repo available to take a peek at what you've got so far?

Yes, upcoming are supported! Just set upcoming to true in the episode frontmatter 😊 for example, you can see this episode has upcoming set to false.

chrisreddington commented 1 year ago

@SamGreenwood1 - I think I've identified the issue. When I build the theme, I create a file in data/popular.json to populate the 'most popular posts' section of the site.

It is an array of strings with the relative file path from the BaseURL to the blog post, e.g.:

["/blog/hello-world/", "/blog/build-2021-summary/", "/blog/jamstack-cloud-winning-combination/", "/blog/api-management-and-policies/", "/blog/static-web-apps-vs-storage-account-static-sites/", "/blog/azuredevops-selfhosted-agents-on-azure/", "/blog/secure-app-service-with-easy-auth-and-app-gateway-public/", "/blog/api-management-and-additional-policies/", "/blog/github-action-docker-dotnet-core/", "/blog/using-oidc-github-actions-azure-swa/"]

I suspect that if you add a dummy file with an empty array, you'll get a successful build. I'm going to add a check to verify if the file exists, and contains an array before using that logic.

chrisreddington commented 1 year ago

Hey @SamGreenwood1, I believe this is now fixed in v0.0.28 of the site. Please can you update to that version and let me know whether all is good? Then we can close the issue :) Thanks!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

SamGreenwood1 commented 1 year ago

Sorry, I was working at overnight camp through the summer and didn't have time to continue working on this. I'm still getting that error.