Is there any way to use locally placed jquery libs instead of cdn?

For eg i have following working code in header.html:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.0/jquery.fancybox.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.0/jquery.fancybox.min.css" />

If i try something like with locally placed files:


<script src="assets/js/jquery-3.3.1.min.js"></script>
<script src="assets/js/jquery.fancybox.min.js"></script>
<link rel="stylesheet" href="assets/css/jquery.fancybox.min.css" />

code is simply not working, however the paths to files are correct by opinion of vscodium.

Any thoughts on this?

The assets folder is not exposed to the final website.

If you want to copy a file verbatim to the site, place in the static folder. .everything there will be copied as is to the site root (incl. folder structure) omitting the static

Then reference it with

<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/jquery.fancybox.min.js"></script>
<link rel="stylesheet" href="/css/jquery.fancybox.min.css" />

See Static files | Hugo

Thanks for reply, but it is no use.
I’m using mainroad theme.
Tried to place into static folder of the project, tried to place into static folder of the theme.
No luck.

It answers the question. The Theme would have been valuable info before

Nevertheless the theme provides a config setting for custom css and js

Maybe the theme author may assist there

I don’t know that theme could influence working process.

Tried these lines, no luck also.

 customCSS = ["css/custom.css"] # Include custom CSS files
  customJS = ["js/custom.js"] # Include custom JS files

Will ask author at his github, report here if there will be any answer or i’ll find solution.

Also i find out that there is a thing related code in baseof.html:

<script async defer src="{{ "js/menu.js" | relURL }}"></script>

{{ range .Site.Params.customJS -}}
<script src="{{ . | relURL }}"></script>
{{- end }}

Currently is looking for solution.

Please have a look at Requesting Help for future questions.

It does not make sense to let us step by step check things and then tell you did after. Also provide the contex around.

For four problem

The customCSS and customJS settings work perfectly OOTB if the files are in static folder.
Recheck your settings and all that other stuff you changed

I thought it might be helpful for other people

Just to sum up

/hugo.toml

[Params]
customCSS = ["css/red.css"]
customJS = ["js/jquery.js"]

Put the files in

/static/css/red.css
/static/js/jquery.js

Thank you, already tried it, w/o any luck.

I promise that works with the bare setup according to their docs.

There’s something wrong with your configuration, folder structure…

If you want further assistance share your repo. If not, not

Update: if you serve from a subfolder the params have to without leading slash