Announcing Google Drive Site Publishing

Wednesday, November 28, 2012 | 1:30 PM

Labels:

Would you like to programmatically publish some web content? Or let your users do so in the context of your Drive app?

This is possible now with Google Drive. Your app can now insert static web assets in a publicly shared folder, and then serve those files directly to users via file names in a relative path. Google Drive site publishing supports JavaScript, so it's even possible to run a JavaScript Drive app directly from Drive.

Publishing from Drive is a simple, two-step dance: create a public folder and use a link to the root folder — the webViewLink — to publish its contents. You can refer to the Drive SDK documentation for full detail on how to work with public folders and content links, but basically the requirements are:

  • The folder containing site assets must be public. Assets added to public folders must also be public on the web.
  • Link to the files contained in the folder using the webViewLink (included in the folder’s JSON representation).

It’s important to emphasize the added simplicity provided by a webViewLink: using this link as a starting point, you can extend the path to any web asset in any subfolder without worrying about retrieving the exact file ID. What used to look like 0B2Gk2F2ImIBiaUkwY3JNX1JMaTg is now a recognizably cute path such as images/kittens.jpg. For the root path to the folder, we’ll display a list of files in the folder, or, if you have an index.html file in your folder we’ll load that as expected.

To see Google Drive site publishing in action, check out this example site served from Google Drive at https://googledrive.com/host/0B716ywBKT84AcHZfMWgtNk5aeXM.

The ability to publish files this way opens lots of possibilities for Drive app developers. Writing a blogging tool, creating a process to publish updates to shared docs, outputting images in a folder in a gallery page — any Drive use case that involves presenting a file in a browser can benefit from site publishing. We look forward to seeing what you create, and we’re happy to answer your questions on Stack Overflow.

Eric Gilmore

Eric is a technical writer working with the Developer Relations group. Previously dedicated to Google Apps APIs, he is now busy writing about all aspects of the Google Drive SDK.

43 comments:

Kyle Horst said...

We use Google Sites. :)

Peter said...

Is there a way to do this entirely from the drive.google.com UI? How do I get the webViewLink?

Michael Rees said...

Same question as Peter. How do I determine the webViewLink accessing Google Drive via the browser?

If I create a document with the name index.html via the browser UI will this be recognised as the home page?

Eric G said...

Hi Michael,

Yes it will! In the link to our (admittedly unspectacular) example site, the longish string actually identifies a folder, not a file. When a browser hits a public folder that way, Drive serves up index.html if it exists, or a simple contents page otherwise.

To the question you and Peter both pose: I'll check further, but I believe there is no clean way to do that currently with the UI. Manually, you can inspect folder and file IDs in the URLs and work that way -- but that's probably not what you want. However, this feature is practically begging someone to develop a Drive app that lets users build simple sites, managing the webViewLinks for them in nice GUI . . .

Thanks for the comments!

Peter said...

Yeah; I searched for such a Drive App, but I guess still early days. Thanks!

Bill Bennett said...

Would it be possible to link to this kind of content from, say, a wordpress site?

Waqar Ahmad said...

Wow, most awaited feature. Looks like web hosting companies will have to shut their shops.
I just created a test page and uploaded it to a public folder. See here what I got.
https://googledrive.com/host/0B2MdbzABFW_uTE9kU21yMnl6bUU/

Gerald Antal Gamauf said...

why not 'simply' use gSites?
anybody out there who could document PROs and CONs?

David Warman said...

And yet there is no path to editing html files in Google Drive, at least not in the iPad App. Not even an "unknown file type - edit as text?" option.

Arun Goyal said...

This comment has been removed by the author.

Aaron Dunn said...

Can a custom domain be used to make it prettier?

Mikee said...

Woah, this sounds pretty powerful stuff. Google is basically giving web developers the ability to setup a free CDN using GDrive.

▴triune. said...

Its nt rocket science to figure out your public drive URL. Just create a folder in drive, then go to drive.google.com and share the folder ~ making it public, it will give you a URL like:

https://docs.google.com/folder/d/999-GlkadL3zcVRGSTFLRFZBQWM/edit

its pretty easy to see the ID of the folder there. Then you take that id and turn it into this:

https://googledrive.com/host/999-GlkadL3zcVRGSTFLRFZBQWM/

But I agree... if a folder is public, Google should make it easier and just provide both URLs in the share popup page for less copy and paste ;)

Martin Kalwill said...

Wow, amateur very interested is there any video or website for step by step instructions to set up a
website?

Martin Kalwill said...

would it be free ? no adds?
Can I forward my domain?

Peter said...

@Triune, I tried that; doesn't serve the HTML even though I have an index.html, nor does it allow me to access other resources under that path. I just get a generic UI for the public folder and 404s for anything below that. Thus I assumed the webViewLink ID is different from the normal ID.

But now I notice that the public folder UI is not showing the files either, so problem seems to be that they are public GDocs but somehow not public from the Drive folder?

Peter said...

This comment has been removed by the author.

Peter said...

Okay, problem was that I left conversion to GDocs format on when I uploaded the test doc. Sorry about that.

Next question: how will API keys be handled? Doesn't seem like the old activation by domain setup works for this situation...

Peter said...

Sorry again; I see I am able to put more than just the domain, so it appears that whitelisting an API key with the whole URL up to the end of the ID will work. Thanks!

Peter said...

@David, NeutronDrive seems like a pretty nice HTML editor for Drive on Chrome. Maybe see if there is an iOS version?

Paul Bailey said...

If your looking for this as an end user feature checkout my app:
Neutron Drive

It lets you edit code from Google Drive and I just added support for this today.

Alejandro Rodriguez Mann said...

Will it support css in the future??

Trevor Wright said...

Is Google Drive WordPress compatible, i.e. does it support:
- PHP 5.2.4 or greater
- MySQL 5.0 or greater
- The mod_rewrite Apache module
I suspect not?
Thanks

niu tech said...

Now there is an URL shortening service GDriv.es providing vanity URLs specially for Google Drive hosting.

Eric G said...

It's terrific to see a good discussion like this growing out of a blog post. Also very cool to see a free URL shortener appearing so quickly!

I can try to speak to the Sites vs. Drive question a little. It seems to me that Sites is very friendly to users who prefer a GUI-based way to edit HTML pages. Sites gives such folks precooked widgets to help create common page elements, and lets you easily insert nifty things like maps and Apps Script Gadgets. However, if you write HTML and know what you want your pages to look like (and yes, we do indeed support CSS!) then the Drive option might work better for you. If you have existing assets, you can drop them into a public folder very easily, with full visibility into the folder hierarchy. And as Paul pointed out, it's easy to install an editor like Neutron Drive and edit your files.

Ruke said...

Well, static pages... not to be rude or something like that, but we are in 2012, static pages have no space in this year. You can even create a real hosting business, who in the world world not want to host his entire site in Google service?!

Sorry for my English.
Greetings

Mori said...

This feature is great! Thank you! :)
There’s one drawback though, Drive’s site publishing doesn't appear to support custom domains, which means it works fine for assets like images, CSS or JavaScript, but unless you don’t mind serving your site from some funky URLs, it’s probably not the best choice for hosting an entire site.

niu tech said...

@Mori: That's where GDriv.es comes. You no longer have to deal with "funky" URLs, but your custom aliases. And if you own a domain, you can set a domain redirection using mod_rewrite or frames.

Trevor Wright said...

Eric, can you answer my query about Wordpress compatability?

Many Thanks

Marc Cawood said...

This is a nice POC but far from easy to use or flexible. Why does googledrive.com only support HTTPS for example? This prevents using any resources via HTTP. It seems meaningless to enforce HTTPS here.

Cornel The Librarian said...

Another great feature of Gdrive!

Titan said...

I'm enjoying google drive hosting and now especially gdriv.es. But, I can't get my countdown clock to work. I generated one from countingdownto.com.

ammar said...

Is Google Drive WordPress compatible, i.e. does it support:
- PHP 5.2.4 or greater
- MySQL 5.0 or greater
- The mod_rewrite Apache module
I suspect not?
Thanks

Jim Siegl said...

This only works for Google Apps domains that allow sharing to Public. If you restrict document sharing to the domain (as many K12 schools do) this does not work.

It would be nice if this worked the same way as other file sharing for domain restrictions

Kevin said...

Of course there is always goo.gl as well, remember.

Oliver Jonas said...

This comment has been removed by a blog administrator.

Calion said...

Will/does Google Drive Site Publishing support domain mapping, as Google Sites does? Pretty please?

Robert Duić said...

As I understand it's not possible to use SSI (Server Side Include)...

It seems it's not possible to use relative path as: "../image.jpg" as well.

I I'm wrong let me know, otherwise this are big limitations :(

Mol said...

Hi Eric,

Good info !
But what if I just want to see one htm file uploaded to GDriver ?

Unknown said...

I tried this, but can't get it to work on my Google Drive that's part of Apps for Education. Does the domain name go in there someplace? I tried drive.google.com/host/ and drive.google.com//host and just drive.google.com/host/... as shown, but I'm not able to link.

The folder and file are definitely publically visible. Thanks for any insight!

Yanina Libenson said...

It's possible to host a site in google drive with a custom domain, with http://gweb.io/

Behzad Beheshti said...

This is great! But how can I deny directory listing as explained here:
http://stackoverflow.com/questions/19395306/google-drive-web-hosting-deny-directory-listing

Mori said...

Here's a free HTML Editor for Google Drive: HTML Editey.