Local Development Setup Guide
Overview
This guide explains how to set up the church website for local development with Google Calendar API support.
Prerequisites
- Ruby 3.2+ (check with
ruby --version) - Bundler (check with
bundle --version) - Git
Quick Start (5 minutes)
1. Install Dependencies
cd /Users/t888651/repos-telenor/church
bundle install
2. Get Google API Key
Visit Google Cloud Console:
- Create a new project or select existing one
- Enable Google Calendar API
- Create an API key credential:
- Go to Credentials → Create Credentials → API Key
- Copy the key value
- (Optional) Restrict key to Calendar API only for security
3. Set Up Local Environment
# Copy the template
cp .env.local.template .env.local
# Edit and add your API key
nano .env.local # or use your preferred editor
Example .env.local:
GOOGLE_API_KEY=AIzaSy... (your actual key here)
4. Start Development Server
Option A: Using the convenience script (RECOMMENDED)
./local-dev.sh
Option B: Manual setup
export GOOGLE_API_KEY=$(cat .env.local | grep GOOGLE_API_KEY | cut -d= -f2)
bundle exec jekyll serve --livereload
Then open: http://localhost:4000
Features
The development server includes:
- ✅ Live reload - auto-refresh on file changes
- ✅ Google Calendar API - upcoming events display
- ✅ Draft posts - view drafts with
--draftsflag - ✅ Future posts - view scheduled posts with
--futureflag
File Structure
.env.local # Your local API key (NEVER commit this)
.env.local.template # Template with instructions (safe to commit)
_config.yml # Reads GOOGLE_API_KEY from environment
local-dev.sh # Convenience script to start development
Environment Variables
For Local Development
Set GOOGLE_API_KEY in .env.local:
export GOOGLE_API_KEY=your_key_here
bundle exec jekyll serve
For GitHub Pages (CI/CD)
API key is automatically passed from GitHub Secrets → .github/workflows/jekyll.yml:
env:
GOOGLE_API_KEY: $
Users don’t need to set anything manually for GitHub deployments.
Troubleshooting
Issue: “GOOGLE_API_KEY not configured”
Solution: Verify .env.local exists and has the key:
cat .env.local
Issue: “Bundle install fails”
Solution: Update Ruby and Bundler:
ruby -v # Should be 3.2+
gem install bundler
bundle update
Issue: “Port 4000 already in use”
Solution: Use a different port:
PORT=4001 ./local-dev.sh
Issue: “Calendar events not showing”
Solution: Verify API key is valid:
- Check
.env.localhas the correct key - Verify key is enabled in Google Cloud Console
- Check browser console (F12) for errors
Commands
Start with defaults
./local-dev.sh
Start with custom port
PORT=4001 ./local-dev.sh
Start with drafts (preview draft posts)
export GOOGLE_API_KEY=$(cat .env.local | grep GOOGLE_API_KEY | cut -d= -f2)
bundle exec jekyll serve --drafts --livereload --port 4000
Build for production
export GOOGLE_API_KEY=$(cat .env.local | grep GOOGLE_API_KEY | cut -d= -f2)
bundle exec jekyll build
Build without API key (for testing)
bundle exec jekyll build # GOOGLE_API_KEY will be empty
Security Checklist
✅ .env.local is in .gitignore - won’t be committed
✅ .env.local.template is safe to commit - shows structure only
✅ API key is restricted to Calendar API in Google Cloud
✅ GitHub Secret is protected - not exposed in logs
✅ Never paste real API keys in issues/discussions
GitHub Actions Integration
When you push to main, GitHub Actions automatically:
- ✅ Reads
GOOGLE_API_KEYfrom GitHub Secrets - ✅ Passes it to Jekyll build
- ✅ Builds and deploys to GitHub Pages
- ✅ Calendar events work on the live site
No manual setup needed for GitHub Pages!
Development Workflow
1. Clone repo
git clone https://github.com/user/church.git
cd church
2. Install dependencies
bundle install
3. Set up local environment
cp .env.local.template .env.local
# Edit .env.local with your API key
4. Start development
./local-dev.sh
# Edit files, changes reload automatically
5. Commit changes
git add .
git commit -m "feat: add new content"
git push origin main
6. GitHub Actions deploys automatically
# Check Actions tab to monitor deployment
Testing Calendar Integration
Once the site is running:
- Visit http://localhost:4000/events/
- Should see upcoming events from church calendar
- Check browser console (F12) for any API errors
Questions?
- How do I get the API key? → See “Get Google API Key” section above
- Is my key safe? → Yes,
.env.localis in.gitignore - Can I use the same key on multiple devices? → Yes, but keep it secret
- What if I forget the key? → You can generate a new one in Google Cloud Console
References
Next Steps
- ✅ Copy
.env.local.template→.env.local - ✅ Add GOOGLE_API_KEY to
.env.local - ✅ Run
./local-dev.sh - ✅ Open http://localhost:4000
- ✅ Start developing!
Happy developing! 🚀