Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom JS files are not copied to public/js folder #1697

Closed
davxiao opened this issue May 14, 2020 · 4 comments
Closed

Custom JS files are not copied to public/js folder #1697

davxiao opened this issue May 14, 2020 · 4 comments

Comments

@davxiao
Copy link

davxiao commented May 14, 2020

Custom JS files place in assets/js/ folder are not copied into public/js folder.

See below for directory structure

assets
└── js
    ├── jquery.js
    └── node_modules
        ├── jquery
        │   ├── dist
        │   │   ├── jquery.js
        │   │   ├── jquery.min.js
        │   │   ├── jquery.min.map
        │   │   ├── jquery.slim.js
        │   │   ├── jquery.slim.min.js
        │   │   └── jquery.slim.min.map
        │   └── package.json

I've followed the instructions at https://sourcethemes.com/academic/docs/customization/#add-scripts-js and added jquery.js to params.toml

Hugo version 0.7.0, latest version Hugo-academic. Any suggestions? Much appreciated.

@gcushen
Copy link
Collaborator

gcushen commented May 14, 2020

for your own local scripts, let’s say that you have a JS file named custom.js. We can place your file in assets/js/ (create the folders within your website root if they don’t exist). Then open your config/_default/params.toml and set plugins_js = ["custom"], where custom is your JS filename without its extension.

Can you show the relevant line of your params.toml? Did you specify just the filename without the .js extension?

@davxiao
Copy link
Author

davxiao commented May 14, 2020

In params.toml

# Load JS plugins
#   E.g. To load `/assets/js/custom.js`, set `plugins_js = ["custom"]`.
plugins_js  = ["jquery"]

I can confirm assets/js/jquery.js exists.

After ran hugo, I checked the public/js directory it generated, it has only the following files:

academic.min.01f19851374de3eb9e5c5e6b18db5b9f.js
academic.min.37431be2d92d7fb0160054761ab79602.js
mathjax-config.js
vendor

@gcushen
Copy link
Collaborator

gcushen commented May 14, 2020

The custom script should be included in the academic.min.*.js file.

@gcushen
Copy link
Collaborator

gcushen commented May 14, 2020

Alternatively, if you are looking to self-host the integrated assets rather than using third party CDN, there is a guide here https://sourcethemes.com/academic/docs/offline-site/

@gcushen gcushen closed this as completed May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants