You can get the url for webapp through ScriptApp:
<a href="<?= ScriptApp.getService().getUrl() + "?item=xyz" ?>" >Item xyz link</a>
and you can get the URL on sites through SitesApp:
SitesApp.getActivePage().getUrl()
although I donβt think this is really useful for what you seem to be describing, since you cannot add useful query parameters to it. Scripts are executed in an iframe, so although you can use document.location on the client, this will not help in any way. The URL is cleared and the service identifier is deleted.
source share