You’re have several mistakes,
-
The path is the ‘/home’ or ‘/contact’ part of the url.
-
In line 6 the url (which should only be the path) had to be in-between equation marks.
-
But actually it should be const currentPath = wixSite.currentPage?.url; as in my code.
-
As you can see my code was referring to the masterPage.js and you mistakenly put it in home page code.