{"id":344580,"date":"2021-07-22T07:44:26","date_gmt":"2021-07-22T14:44:26","guid":{"rendered":"https:\/\/css-tricks.com\/?p=344580"},"modified":"2021-08-02T18:56:57","modified_gmt":"2021-08-03T01:56:57","slug":"using-google-drive-as-a-cms","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/using-google-drive-as-a-cms\/","title":{"rendered":"Using Google Drive as a CMS"},"content":{"rendered":"\n

We\u2019re going to walk through the technical process of hooking into Google Drive\u2019s API to source content on a website. We\u2019ll examine the step-by-step implementation, as well as how to utilize server-side caching to avoid the major pitfalls to avoid such as API usage limits and image hotlinking. A ready-to-use npm package, Git repo, and Docker image are provided throughout the article.<\/p>\n\n\n\n\n\n\n

But\u2026 why?<\/h3>\n\n\n

At some point in the development of a website, a crossroads is reached: how is content managed when the person managing it isn\u2019t technically savvy? If the content is managed by developers indefinitely, pure HTML and CSS will suffice \u2014 but this prevents wider team collaboration; besides, no developer wants to be on the hook for content updates in perpetuity.<\/p>\n\n\n\n

So what happens when a new non-technical partner needs to gain edit access? This could be a designer, a product manager, a marketing person, a company executive, or even an end customer.<\/p>\n\n\n\n

That\u2019s what a good content management system is for, right? Maybe something like WordPress. But this comes with its own set up of disadvantages: it\u2019s a new platform for your team to juggle, a new interface to learn, and a new vector for potential attackers. It requires creating templates, a format with its own syntax and idiosyncrasies. Custom or third-party plugins may need to be to vetted, installed, and configured for unique use cases \u2014 and each of these is yet another source of complexity, friction, technical debt, and risk. The bloat of all this setup may end up cramping your tech in a way which is counterproductive to the actual purpose of the website.<\/p>\n\n\n\n

What if we could pull content from where it already is? That\u2019s what we\u2019re getting at here. Many of the places where I have worked use Google Drive to organize and share files, and that includes things like blog and landing page content drafts. Could we utilize Google Drive\u2019s API to import a Google Doc directly into a site as raw HTML, with a simple REST request?<\/p>\n\n\n\n

Of course we can! Here\u2019s how we did it where I work.<\/p>\n\n\n

What you’ll need<\/h3>\n\n\n

Just a few things you may want to check out as we get started:<\/p>\n\n\n\n