I cannot run the script despite following instructions

I added the script file inside the folder called js and added the corresponding line into the footer template (the first line).

		<script src="/js/back-to-top.min.js"></script>
		<script src="/js/skel.min.js"></script>
		<script src="/js/util.js"></script>
		<script src="/js/main.js"></script>
		{{ template "_internal/google_analytics_async.html" . }}

Then I put this info into the page’s markdown file where I want my back-to-top button to be seen.

js = ["chart", "back-to-top.min"]
title = "Çözümler"
weight = "5"
draft = "false"


What am I missing here?

UPDATE: When I just add the code below to the footer.html I can see the button but it sends me to the main page not to the top of the current page.

<script src="https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js"></script>
  diameter: 56,
  backgroundColor: 'rgb(255, 82, 82)',
  textColor: '#fff'

Where did you add your folder? This should live in static

You should use relURL or absURL when getting assets.

This has nothing to do with hugo :slight_smile:

I added the file inside js folder which is by default located under static folder. I am trying to use this feature which is mentioned by the author that it works with Hugo

You should contact the author then.

So, you are telling me that I cannot use js files locally with Hugo? My question is that why the Hugo cannot load the js file inside Hugo file structure. I can solve the rest myself hopefully.


Of course you can. Create a folder static/JS from the root of your project and put your JS files in there. Otherwise, please share source code and be sure to check your JS console/dev tools to make sure your paths are correct.

Is it me mis-reading it, or did you say you added “this info” into your pages markdown file where you want the back-to-top button to be seen… except that where you’ve put it looks like front matter… which is not a “place” on your page, just metadata that can be used.

I have managed to locate the correct path to use the *js file locally. Thanks
Hovewer, when i click the arrow, it sends me to the main page instead of sending me to the very top of the page i am on. I know it is something to do with Hugo for sure. I am not a web developer and I am sorry if I am posting something out of topic here. My site is here if anyone wants to give a hand on this script issue, thanks

From what I see the script you use changes the URL location hash when the back to top button is clicked. It does not redirect the user to the home page because the user is already on the home page.

For example when scrolling down at the location hash https://ozanweb.github.io/#solutions once I click the button the content fades out and the location hash is changed to https://ozanweb.github.io/#

Your issue has nothing to do with Hugo.

You may try another script but from what I gather your theme already uses some other JS function or CSS to fade in content once a menu option is clicked.

I doubt that you will get what you want with this theme.

Also your menu disappears when the content is loaded. What is the point of scrolling to the top of the content if the menu is not visible?

Your page is functional as is. If this not what you want try a different theme.

I’m not closing this thread (like I did your other one) but this is also OT.

(If another moderator feels that this should be closed he/she may do it).

Thanks for not locking it, I really appreciate your time. If you notice, I always share the solution I find at the end of each thread created by me. So I do not want to be seen like a spammer here since my only aim is to develop my Hugo/html skill. The page located at https://ozanweb.github.io/#solutions has links at the top. I want the reader not to get lost on this “long” page where many items are listed. This is my second theme and I am too lazy to change it third time.

Thank you anyway

In that case you need to find or write a script that does not change the URL location hash and when called scrolls the page to the top of the viewport.

P.S. I hardly speak any Turkish but anyway, iyi geceler. :crescent_moon:

1 Like