NJAldwin / eleventy-plugin-gen-favicons

Favicon generator plugin for eleventy
MIT License
15 stars 4 forks source link

Error with Nunjucks shortcode #8

Closed website-user closed 5 months ago

website-user commented 1 year ago

Hey there, Thanks for making this plugin!

I'm having an issue.

From what I can tell, the issue is that the plugin cannot find the svg file.

I can see that the image is in my _site/img directory at build.

I'm using the eleventy-base-blog template, which uses .njk template files. I've followed the installation instructions to the T, twice, from the npmjs.com page, and gotten the same issue.

This is the line I've put at the end of the <head> section in my base.njk template file: {% favicons "/img/favicon.svg" %}

I've tried formatting it as: {% favicons "favicon.svg" %} {% favicons "/favicon.svg" %} {% favicons "./favicon.svg" %} {% favicons "/img/favicon.svg" %} {% favicons "./img/favicon.svg" %}

I've tried using ' quotes and " quotes.

I've tried renaming it favicon_0001.svg

I've tried loading .png version of the file.

So far, nothing works.

This is the error message that comes up when I try to build:

[11ty/eleventy-base-blog] Excluding drafts.
[11ty] Writing _site/sitemap.xml from ./content/sitemap/sitemap.xml.njk
[11ty] Writing _site/feed/feed.json from ./content/feed/json.njk
[11ty] Writing _site/feed/feed.xml from ./content/feed/feed.njk
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble writing to "_site/contact/index.html" from "./content/contact.md" (via EleventyTemplateError)
[11ty] 2. (./_includes/layouts/base.njk)
[11ty]   EleventyShortcodeError: Error with Nunjucks shortcode `favicons` (via Template render error)
[11ty] 3. ENOENT: no such file or directory, stat '/img/favicon.svg' (via Template render error)
[11ty] 
[11ty] Original error stack trace: Error: ENOENT: no such file or directory, stat '/img/favicon.svg'
[11ty] Copied 45 files / Wrote 0 files in 1.31 seconds (v2.0.1)

Any ideas?

Thank you, Liam

heyainsleymae commented 1 year ago

The path provided to the shortcode should be from the root of the project; for eleventy-base-blog, that means your path would begin with the public folder: either public/img/favicon.svg or ./public/img/favicon.svg should work!

website-user commented 11 months ago

Ah amazing! That worked. Thank you very much.