How can I change whole site color with toggle a button

You’re have several mistakes,

  1. The path is the ‘/home’ or ‘/contact’ part of the url.

  2. In line 6 the url (which should only be the path) had to be in-between equation marks.

  3. But actually it should be const currentPath = wixSite.currentPage?.url; as in my code.

  4. As you can see my code was referring to the masterPage.js and you mistakenly put it in home page code.