If you have some content you’d like to embed into a new Google Site that isn’t accepted by the ‘Embed URL’ feature in Sites you can try following these steps:
function
doGet() {
return
HtmlService.createHtmlOutputFromFile('Index')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
- You can replace the existing function in the Script Editor. The doGet() function is required to tell the script how to serve the page
- To add an HTML file to your Apps Script project, click File > New > Html file and enter the name ‘Index’ – this name must match the one given in the doGet() function
- In the Index.html file paste the embed code in the body section
- (between the <body> and </body> tags).
- From the Script Editor click File > Rename and give your project a name before clicking File > Save all
- To allow us to embed in Google Sites you need to deploy your script as a web app by selecting Publish > Deploy as web app
- In the dialog provide a project version name and select who has access to the app (for anyone to view select ‘Anyone, even anonymously’)
- When you click ‘Deploy’ you will be given a ‘Current web app URL’ which will be like
https://script.google.com/macros/s/RANDOM_ID_HERE/exec
- Open your Google Site and on the page you want to include your embedded object select Insert > Embed URL and paste the ‘Current web app URL’ and then click ADD.
- Important: If you change the code in the Index.html file you need to repeat steps 6 and 7 for the changes to take effect.
- This solution is not limited to Twitter and suitable for other services that require their own Javascript files.