Plugin doesn't load

I’ve been trying to add a responsive menu (Responsive Nav ) to my website, but fail to make it work.

My browser is notifying of following errors:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found)
https://www.mysite.com/kirby/responsive-nav.js
[Error] Failed to load resource: the server responded with a status of 404 (Not Found)
https://www.mysite.com/kirby/responsive-nav.css
ReferenceError: Can't find variable: responsiveNav

I have followed the usage instructions presented in the plugin’s GitHub-page and I have tried different ways to place the assets including the one suggested in the Kirby documentation (https://getkirby.com/docs/developer-guide/plugins/assets):

/site/plugins/myplugin/assets/css/myplugin.css
/site/plugins/myplugin/assets/js/myplugin.js

Can anyone point out where the problem could be? Thank you already in advance for any help or advice.

Plugin assets is not the right place, it’s only for Kirby plugins, not for Javascript stuff. You should put your files into assets/js and then include the link tag for the js and css files between the <head></head> tags in the header snippet.

For easier referencing, you can use the css() and js() helpers.

For example, if the file responsive-nav.min.js is located in /assets/js/responsive-nav/responsive-nav.min.js

<?= js('assets/js/responsive-nav/responsive-nav.min.js') ?>

And for the css:

<?= css('assets/js/responsive-nav/responsive-nav.css') ?>
1 Like

from: https://getkirby.com/docs/developer-guide/plugins/assets

All plugin assets must go into an assets folder.

/site/plugins/{pluginName}/assets

maybe this don’t work:

As long as you store your assets in the assets folder, your assets are publicly available at the following URL:

http://{domain}/assets/plugins/{pluginName}/{optionalSubfolder}/{filename}

or maybe there are some overriding files?

Your plugin users can customize your stylesheets, images, or any other asset, by copying the orginal from the plugin’s asset folder to the actual asset location /assets/plugins/{pluginName} as pointed out by the URL. The server will then pick the custom file instead of running the route to the original plugin asset.

@Svnt: Responsive Nav is some JavaScript, not a Kirby plugin. It does not make sense to put it in the plugins folder at all.

Thank you texnixe, now it works!

Maybe this answer should have been obvious, but for some reason it wasn’t. :relaxed:

Anyway this solved the problem, thanks once again! :grinning: :+1:

1 Like