javascriptgoogle-apps-scriptgoogle-sites-2016

How can I call a Google script from a Google site? (2022, "new" Sites)


TL;DR. See the accepted solution below, but in short: you cant do it!

OP frustration: it's infuriating that I could easily get to very clear documentation suggesting that this was still possible, while approaching this from another direction leads to equally clear documentation saying that it's not.


I'm trying to use Google Scripts to get (simple) access to the Sheets API. Tutorials on how to use Scripts from within a Google Sheet work fine for me. But I'd like to have the script run from a Google Site (so I can construct some HTML to display a result to the user). And I'm stuck really early in the process.

In my reading of the google docs, this link: https://developers.google.com/apps-script/guides/menus explains that I need to ...

  1. In a Google Site, click More > Manage site
  2. In the sidebar, click Apps Scripts, then Add new script to create a script that is bound to the site.

As I see it, the kebab menu, upper right by the edit window in the Site, is the More menu; and mine looks like the illustration below. No Manage site item. How do I attach a script to the site?

Then, to call the function you write in the script, they say...

  1. Return to the Google Site and edit a page. Type a label that will become a link, such as Click me, then highlight the text and select Insert > Link.

As with the other issue, when I highlight text (or right-click selected text, or...), I see no menu or other command.

Looking through older documentation, I wonder if this was the strategy for the "classic" Google Sites, but of course we're supposed to use "new" sites since 2021.

I have a feeling that I'm missing something simple, and would be grateful for help!

More menu: Version history, Make a copy, etc.


Solution

  • All I can say is that this documentation is outdated and is already unavailable.

    Script support for Google Sites (Sites Service for Apps Script) was already discontinued after the rebuilt version was released back in 2016.

    Only the classic Google Sites can have script support. (Which means only those already created before the newer version's release is still supported and all created sites after that will not have any script support)

    Discontinued:

    discontinued

    Even the actual API is limited to the classic Google Sites:

    Sites API:

    api

    If what you want is to have a script that shows data from sheets to your site, what you could do is create a webapp and then embed it to your site. See references for more information.

    Reference: