I have a folder in Google Drive that I'd like to embed in my website. I can't find an embed code or anything documented in Google Drive Help articles.
How Embed Works? Go to drive.google.com, right-click any image file, and choose Get Link to get a shareable link of that image. Make sure that the access is set to Anyone on the internet with this link can view. Paste that file link in the box below to generate the HTML embed code.
Click on the three-dot icon and then choose “Open in new window”. This is a critical step and can be easily overlooked, but will give us a new option. In the new window, click on the three-dot icon and choose “Embed item”. Copy the provided HTML embed code, and paste it into your platform of choice.
You can make a document, spreadsheet, presentation or form available to view on an existing website by embedding it in your site or blog. Open a file in Google Docs, Sheets or Slides. Publish to web. In the window that appears, click Embed.
Google Drive folders can be embedded and displayed in list
and grid
views:
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#list" style="width:100%; height:600px; border:0;"></iframe>
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>
Q: What is a folder ID (FOLDER-ID) and how can I get it?
A: Go to Google Drive >> open the folder >> look at its URL in the address bar of your browser. For example:
Folder URL: https://drive.google.com/drive/folders/0B1iqp0kGPjWsNDg5NWFlZjEtN2IwZC00NmZiLWE3MjktYTE2ZjZjNTZiMDY2
Folder ID:
0B1iqp0kGPjWsNDg5NWFlZjEtN2IwZC00NmZiLWE3MjktYTE2ZjZjNTZiMDY2
This technique works best for folders with public access. Folders that are shared only with certain Google accounts will cause trouble when you embed them this way. At the time of this edit, a message "You need permission" appears, with some buttons to help you "Request access" or "Switch accounts" (or possibly sign-in to a Google account). The Javascript in these buttons doesn't work properly inside an IFRAME
in Chrome.
Read more at https://productforums.google.com/forum/#!msg/drive/GpVgCobPL2Y/_Xt7sMc1WzoJ
Google Drive folders can be embedded and displayed in list
and grid
views (in which all you can do is click a file or folder to open it on a new tab). To do so, simply replace FOLDER-ID with your own in:
List view
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#list" style="width:100%; height:600px; border:0;"></iframe>
or without specifying a mode, since list mode is the default:
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID" style="width:100%; height:600px; border:0;"></iframe>
Grid view
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>
The id is the hash (alphanumeric gibberish) after folders/
in the URL of the folder. You can see the URL in the address bar of your browser when you open the Drive folder. For example, in:
https://drive.google.com/drive/folders/0B1iqp0kGPjWsNDg5NWFlZjEtN2IwZC00NmZiLWE3MjktYTE2ZjZjNTZiMDY2
The Folder ID is 0B1iqp0kGPjWsNDg5NWFlZjEtN2IwZC00NmZiLWE3MjktYTE2ZjZjNTZiMDY2
.
If your folder is part of a Google Apps domain, you can add the domain to the URL to alleviate the permission problems (detailed further ahead):
<iframe src="https://drive.google.com/a/MY.DOMAIN.COM/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>
Just replace MY.DOMAIN.COM and FOLDER-ID with your own.
This technique works best for folders with public access. Folders that are shared only with certain Google accounts can cause trouble when you embed them this way, depending on which Google accounts are active on the user's browser:
The blank frames are because Google forbids embedding its login page in an IFRAME (presumably to prevent account stealing), via the X-Frame-Options
header, which if set to SAMEORIGIN
will cause any well-behaved browser to refuse to load the page if it's not in the same domain (v.g. drive.google.com
). You can see this in the developer console of your browser.
To get a list or grid view of a Drive folder (in which all you can do is click a file or folder to open it on a new tab), use:
<iframe src="https://drive.google.com/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>
or alternatively, for a Google Suite/Apps Drive:
<iframe src="https://drive.google.com/a/MY.DOMAIN.COM/embeddedfolderview?id=FOLDER-ID#grid" style="width:100%; height:600px; border:0;"></iframe>
Replace MY.DOMAIN.COM and FOLDER-ID with your own; remove #grid
to get a detailed file list.
For private folders, have your users log to the correct account before loading the page with the embedded folder; if the folder is in a Google Apps domain, you can add the domain to the URL. Else, they must log into the authorised account before any other.
(this answer is an edit of Mori's, but it was rejected as it changed his intent, somehow)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With