|
| 1 | +# Event URL Redirect Management |
| 2 | + |
| 3 | +This guide explains how to manage redirects for your Jekyll-generated event pages to prevent broken links when titles change. |
| 4 | + |
| 5 | +## How It Works |
| 6 | + |
| 7 | +1. **Stable URLs**: Event pages are now generated using stable `slug` fields instead of titles |
| 8 | +2. **Automatic Redirects**: When you change a title, add the old URL to `redirect_from` array |
| 9 | +3. **SEO-Friendly**: Redirects use proper HTTP redirects and canonical URLs |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +The setup includes: |
| 14 | +- **Modified `_config.yml`**: Uses `slug` field for URL generation |
| 15 | +- **Custom Plugin**: `_plugins/datapage_redirect_generator.rb` handles redirects |
| 16 | +- **Redirect Layout**: `_layouts/redirect.html` creates proper redirect pages |
| 17 | + |
| 18 | +## Managing Redirects |
| 19 | + |
| 20 | +### Step 1: Generate Slugs |
| 21 | +Run the management script to ensure all events have stable slugs: |
| 22 | +```bash |
| 23 | +ruby manage_redirects.rb |
| 24 | +``` |
| 25 | + |
| 26 | +### Step 2: Update Event Data |
| 27 | +When changing a title, follow this pattern in `_data/events.yml`: |
| 28 | + |
| 29 | +```yaml |
| 30 | +- id: 34 |
| 31 | + title: "New Updated Title" # New title |
| 32 | + slug: "stable-slug-name" # Keep this the same! |
| 33 | + redirect_from: # Add old URLs here |
| 34 | + - "/events/meetup/old-title-slug" |
| 35 | + - "/events/meetup/another-old-url" |
| 36 | + # ... rest of event data |
| 37 | +``` |
| 38 | + |
| 39 | +### Step 3: Build and Deploy |
| 40 | +```bash |
| 41 | +bundle exec jekyll build |
| 42 | +``` |
| 43 | + |
| 44 | +## Example Scenario |
| 45 | + |
| 46 | +**Original Event:** |
| 47 | +```yaml |
| 48 | +- id: 34 |
| 49 | + title: "Beyond k8s and OpenSource Metrics" |
| 50 | + slug: "beyond-k8s-and-opensource-metrics" |
| 51 | +``` |
| 52 | +URL: `/events/meetup/beyond-k8s-and-opensource-metrics/` |
| 53 | + |
| 54 | +**After Title Change:** |
| 55 | +```yaml |
| 56 | +- id: 34 |
| 57 | + title: "Advanced Kubernetes and Metrics" # New title |
| 58 | + slug: "beyond-k8s-and-opensource-metrics" # Same slug = same URL |
| 59 | + redirect_from: |
| 60 | + - "/events/meetup/34-cloud-native-computing-linz-meetup" # Old URL still works |
| 61 | +``` |
| 62 | + |
| 63 | +## Benefits |
| 64 | + |
| 65 | +1. **No Broken Links**: Old URLs automatically redirect to new ones |
| 66 | +2. **SEO Preserved**: Search engines follow redirects properly |
| 67 | +3. **User-Friendly**: Visitors never see 404 errors |
| 68 | +4. **Future-Proof**: Easy to add more redirects as needed |
| 69 | + |
| 70 | +## Testing |
| 71 | + |
| 72 | +1. Build the site: `bundle exec jekyll build` |
| 73 | +2. Serve locally: `bundle exec jekyll serve` |
| 74 | +3. Test old URLs in browser to confirm redirects work |
| 75 | +4. Check that new URLs display the correct content |
| 76 | + |
| 77 | +## Maintenance |
| 78 | + |
| 79 | +- Keep slugs stable once created |
| 80 | +- Always add old URLs to `redirect_from` when changing titles |
| 81 | +- Run `ruby manage_redirects.rb` to ensure all events have slugs |
| 82 | +- Regularly test redirects after deployments |
0 commit comments