Is it possible to get the hostname of the current page?
currentPage.getPath() only returns something like '/path/path/page' but I also need to find the hostname, for example, 'https://www.google.com'
Is it possible? Or is there a good way of doing it?
Yes, it's possible. Check out the Externalizer service  for access to the hostname, and the Sightly Use-API  for exposing that value to your Sightly scripts.