wixLocation.path.join returns "yoursitename" instead of the dynamic page item title

I’m trying to create a next/previous buttons, so I’ve used the
const currentPage = ‘/’ + wixLocation.prefix + ‘/’ + wixLocation.path.join(‘/’);
line to get the dynamic page item url,
and instead of getting /gallery/expected-item-title, I got yoursitename instead.
I’ve followed the exact instruction in https://support.wix.com/en/article/velo-tutorial-creating-previous-and-next-buttons-for-a-dynamic-item-page-with-code and got no luck with this.
Really need your help guys!