How to add JavaScript code in Hexo without modifying theme files
I use the next theme, but I don’t want to modify the source files, so I use git submodule to check out the next theme. However, I want to add some JavaScript code to the page.
Actually, if you look at _config.next.yml, you will find out how to change it.
- Create a
_datafolder undersource - Create a
footer.swigfile under the_datafolder - Add your JavaScript code to the
footer.swigfile - Change
custom_file_pathin_config.next.ymland add thefooter.swigfile to it
Done~
I simply added the coinimp code, and it was blocked by AdBlock as expected. Anyway, it is only for testing. Adjusted the throttle to 0.1 and turned on the prompt. If it’s blocked, let it be blocked…