Setup Guide: Automated Google Docs to Jekyll Publishing
This guide will help you set up automatic publishing from Google Docs to your Jekyll site. Once configured, any document you add to a specific Google Drive folder will automatically be published to your site within an hour.
Prerequisites
- Google account
- GitHub account with your Jekyll repository
- 20 minutes for setup
Part 1: Create Your “Blog Posts” Folder (2 minutes)
Step 1: Create the Watch Folder
- Go to Google Drive
- Click New ? Folder
- Name it “Blog Posts” (or any name you prefer)
- Click Create
Step 2: Get the Folder ID
- Open the “Blog Posts” folder
- Look at the URL in your browser’s address bar:
- Copy the long string after /folders/ - this is your Folder ID
- Save it somewhere - you’ll need it in Step 8
Part 2: Generate GitHub Personal Access Token (5 minutes)
Step 3: Create GitHub Token
- Go to GitHub Settings
- Click Developer settings (bottom of left sidebar)
- Click Personal access tokens ? Tokens (classic)
- Click Generate new token ? Generate new token (classic)
Step 4: Configure Token
- Note: Enter “Jekyll Auto-Publisher”
- Expiration: Select “No expiration” (or set a custom date)
- Select scopes: Check ? repo (this gives full control of private repositories)
- This will automatically check all sub-options under “repo”
- Scroll to bottom and click Generate token
Step 5: Save Your Token
- You’ll see a green box with your token (starts with ghp_)
- IMPORTANT: Copy this token immediately - you can only see it once!
- Save it in a secure location (password manager, secure note, etc.)
- You’ll paste this into the script in Step 8 Security Note: Treat this token like a password. Anyone with this token can access your repository.
Part 3: Install the Automated Script (5 minutes)
Step 6: Create Apps Script Project
- Go to Google Apps Script
- Click New project (top left)
- You’ll see a new project with default code
Step 7: Add the Script
- Delete all existing code in the editor (select all and delete)
- Copy the entire automated script I provided above
- Paste it into the editor
- Click the disk icon (?) or press Ctrl+S to save
- At the top, click “Untitled project” and rename it to “Jekyll Auto-Publisher”
- Click OK
Step 8: Configure Your Settings
Find this section at the top of the script and update it with your information:
Replace:
- YOUR_GITHUB_PERSONAL_ACCESS_TOKEN with your token from Step 5
- YOUR_GITHUB_USERNAME with your GitHub username
- YOUR_REPO_NAME with your repository name
- YOUR_GOOGLE_DRIVE_FOLDER_ID with your folder ID from Step 2 Save the script again after making changes.
Step 9: Test the Script
Before automating, let’s test that everything works:
- In the Apps Script editor, find the function dropdown (near the top)
- Select testAutomation from the dropdown
- Click the Run button (?? play icon)
- First time only: You’ll be asked to authorize:
- Click Review Permissions
- Choose your Google account
- Click Advanced ? Go to Jekyll Auto-Publisher (unsafe)
- Click Allow
- Wait for the script to finish (watch the “Execution log” at bottom)
- Check the logs - you should see “Test complete” If you get errors: Check the execution log for details. Common issues:
- Folder ID is wrong
- GitHub token is invalid
- Repository name is misspelled
Part 4: Set Up Automatic Running (3 minutes)
Step 10: Create Time-Based Trigger
- In the Apps Script editor, click the clock icon (?) on the left sidebar
- This is the “Triggers” section
- Click Add Trigger (bottom right)
- Configure the trigger:
- Choose which function to run: checkForNewPosts
- Choose which deployment should run: Head
- Select event source: Time-driven
- Select type of time based trigger: Hour timer
- Select hour interval: Every hour
- Click Save
Step 11: Confirm Trigger is Active
- You should now see your trigger in the list
- It will show:
- Function: checkForNewPosts
- Event: Time-driven, Every hour
- Status: Enabled (if there’s a toggle, make sure it’s on) That’s it! Your automation is now running.
Part 5: Using Your Automated System (2 minutes per post)
Publishing a New Post
- Create a Google Doc in your “Blog Posts” folder:
- Go to your “Blog Posts” folder in Google Drive
- Click New ? Google Docs
- Give it a meaningful title (this becomes your post title)
- Write your post:
- Use Heading 1, 2, 3 for structure
- Add bold, italic, links as normal
- Insert images anywhere in the document
- Write naturally - no need to think about Markdown
- Wait up to 1 hour:
- The script runs every hour
- It will detect your new document
- Convert it to Markdown
- Push to GitHub
- Your site rebuilds automatically
- Check your site:
- After GitHub Pages rebuilds (1-2 minutes)
- Your post should be live!
Creating a Draft
To work on a post without publishing yet:
- Prefix the title with “DRAFT:”
- Example: “DRAFT: My Upcoming Tutorial”
- Write as much as you want
- When ready to publish: Remove “DRAFT:” from the title
- Within an hour, it will auto-publish
Updating a Published Post
- Edit the Google Doc in your “Blog Posts” folder
- Make your changes
- Save (Ctrl+S or Cmd+S)
- Within an hour, changes will be live on your site
Deleting a Post
- Remove the doc from “Blog Posts” folder
- Move it to another folder or trash it
- Manually delete from GitHub:
- Go to your repository on GitHub
- Navigate to _posts/ folder
- Find the post file
- Click it ? Click trash icon ? Commit deletion Note: Automated deletion is intentionally not included to prevent accidental data loss.
Part 6: Monitoring & Maintenance
View Execution Logs
To see what the automation is doing:
- Open Apps Script
- Open your “Jekyll Auto-Publisher” project
- Click Executions icon on left sidebar (looks like a list)
- You’ll see every run with:
- Date/time
- Status (Success/Failed)
- Duration
- Click any execution to see detailed logs
Understanding the Logs
Successful run looks like:
Email Notifications (Optional)
To get emailed when posts are published:
- Open your script
- Find the CONFIG section
- Change these lines:
- Save the script
- You’ll now get emails summarizing what was published
Reset Everything (Use with Caution)
If you need to republish all posts:
- In Apps Script editor, select function: resetAllTracking
- Click Run
- Confirm you want to reset
- All posts will be republished on next hourly run Warning: This will overwrite any manual edits you made directly on GitHub.
Troubleshooting
Posts aren’t publishing
Check these:
- ? Trigger is enabled (clock icon in Apps Script)
- ? Document is in correct folder
- ? Document doesn’t start with “DRAFT:”
- ? Execution log shows no errors
- ? GitHub token is valid
- ? Repository name is spelled correctly
Images aren’t showing
Check these:
- ? Images are in document (not just links)
- ? imagesPath in CONFIG matches your Jekyll setup
- ? Check GitHub - are images actually uploaded?
- ? Check markdown file - are image paths correct?
“Authorization required” error
Fix:
- Go to Apps Script editor
- Click Run to re-authorize
- Follow authorization prompts again
GitHub API rate limit
If you hit limits:
- GitHub allows 5000 requests per hour
- Each post uses ~1-5 requests (depending on images)
- You’re very unlikely to hit this limit
- If you do, wait an hour and try again
Script times out
If processing takes too long:
- Reduce number of images per post
- Or split large posts into multiple documents
- Google limits script execution to 6 minutes
Security Best Practices
Protecting Your Token
- ? Never share your GitHub token
- ? Never commit the script to a public repo
- ? Rotate token periodically (regenerate every 6-12 months)
- ? Use minimum permissions (only “repo” scope)
- ? Revoke immediately if compromised
Revoking a Token
If your token is compromised:
- Go to GitHub Tokens
- Find “Jekyll Auto-Publisher”
- Click Delete
- Generate a new token
- Update the script with new token
Advanced Customization
Change Check Frequency
To check daily instead of hourly:
- Go to Triggers (clock icon)
- Click the three dots next to your trigger
- Click Edit
- Change “Hour timer” to “Day timer”
- Choose time of day
- Save
Multiple Folders
To watch multiple folders:
- Create additional folders in Google Drive
- Get their folder IDs
- Duplicate the trigger in Apps Script
- Create a second CONFIG for the new folder
- Modify checkForNewPosts() to use different CONFIG based on trigger
Custom Commit Messages
To include post title in commit:
Find this line in the script:
Change to:
Different Author Per Post
To support multiple authors:
Add a custom property to each Google Doc:
- File ? File properties ? Custom properties
- Add property: author = “Author Name”
- Modify script to read this property
What’s Happening Behind the Scenes
Every hour, the script:
- ? Checks the “Blog Posts” folder
- ? Compares each doc’s last modified date
- ? For new/updated docs (not starting with “DRAFT:”):
- Converts to Markdown with Jekyll frontmatter
- Extracts all images
- Generates proper filenames
- ? Pushes to GitHub:
- Creates/updates markdown file in _posts/
- Uploads images to assets/images/
- Makes a commit
- ? Marks documents as processed
- ? Logs results
? Sends notification (if enabled) GitHub Pages then:
- Detects the new commit
- Rebuilds your Jekyll site
- Deploys updated site (1-2 minutes)
Cost Breakdown
Total Cost: $0.00
- Google Apps Script: Free
- Google Drive storage: Free (15GB)
- GitHub repository: Free (public repos)
- GitHub Pages hosting: Free
Script executions: Free (within generous limits) Limits to be aware of:
- Google Apps Script: 6 minute max per execution
- Google Apps Script: 90 minutes total per day
- GitHub API: 5000 requests per hour
- GitHub Pages: 100GB bandwidth per month You’re very unlikely to hit any of these limits with normal blog usage.
Success Checklist
Before you start using the system, verify:
- ? “Blog Posts” folder created in Google Drive
- ? Folder ID copied and pasted into script
- ? GitHub personal access token created
- ? Token pasted into script
- ? GitHub username and repo name correct in script
- ? Script saved in Apps Script
- ? Test run successful (no errors)
- ? Hourly trigger created and enabled
- ? Test post created and published successfully
Your Publishing Workflow (Summary)
Going forward, here’s all you need to do:
- Write post in “Blog Posts” folder
- Wait (up to 1 hour)
- Post is live! That’s it. No manual export, no file management, no command line. Just write and publish.
Next Steps
- Create a test post right now to verify everything works
- Check your site in about an hour to see it published
- Start writing your next blog post! Enjoy your automated publishing system! ?
Tagged .