π Redirect Generator Documentation
Automated tool for creating branded affiliate shortlink pages for Th1nkN3st.
π― Purpose
Generate clean, professional redirect URLs like:
https://www.th1nkn3st.com/go/anker67/βhttps://amzn.to/4qhzGluhttps://www.th1nkn3st.com/go/logitechg305/βhttps://amzn.to/47b37wC
β‘ Quick Start
# 1. Edit your product data
nano redirects.csv
# 2. Generate redirect pages
python3 generate_redirects.py redirects.csv
# 3. Test locally
bundle exec jekyll serve
# Visit http://localhost:4000/go/yourslug/
# 4. Deploy
git add go/ redirects.csv
git commit -m "Add new affiliate redirects"
git push
π Data Formats
CSV Format (Recommended)
File: redirects.csv
slug,affiliate_link,product_name
anker67,https://amzn.to/4qhzGlu,Anker Prime 67W
logitechg305,https://amzn.to/47b37wC,Logitech G305
samsungg9,https://amzn.to/477v8VR,Samsung Odyssey G9
Usage:
python3 generate_redirects.py redirects.csv
JSON Format (Alternative)
File: redirects.json
{
"redirects": [
{
"slug": "anker67",
"affiliate_link": "https://amzn.to/4qhzGlu",
"product_name": "Anker Prime 67W"
},
{
"slug": "logitechg305",
"affiliate_link": "https://amzn.to/47b37wC",
"product_name": "Logitech G305"
}
]
}
Usage:
python3 generate_redirects.py redirects.json
π§ Script Features
β
Batch Generation: Create multiple redirects at once
β
Auto-formatting: Proper YAML front matter & HTML
β
Overwrite Safe: Re-run anytime to update existing files
β
Validation: Skips invalid entries automatically
β
Clean Output: Shows exactly what was created
π Field Descriptions
| Field | Required | Description | Example |
|---|---|---|---|
slug |
β Yes | URL-friendly identifier | anker67, logitechg305 |
affiliate_link |
β Yes | Full Amazon shortlink | https://amzn.to/4qhzGlu |
product_name |
β οΈ Optional | Product display name | Anker Prime 67W |
Notes:
slugbecomes the URL:/go/{slug}/product_namedefaults toslugif not provided- Script validates required fields and skips invalid rows
π¨ Generated HTML Structure
Each redirect page includes:
---
layout: default
title: "Redirecting to {product_name}..."
permalink: /go/{slug}/
---
<meta http-equiv="refresh" content="0; url={affiliate_link}">
<link rel="canonical" href="https://www.th1nkn3st.com/go/{slug}/" />
<section style="text-align:center;margin:80px auto;max-width:600px;">
<p>Redirecting you to Amazon...</p>
<p style="font-size:0.9rem;color:#888;">
As an Amazon Associate, Th1nkN3st earns from qualifying purchases.
</p>
<p>If you're not redirected automatically,
<a href="{affiliate_link}">click here</a>.
</p>
</section>
π Typical Workflows
Adding One Product
# Add line to CSV
echo "newslug,https://amzn.to/XXXXX,Product Name" >> redirects.csv
# Regenerate all
python3 generate_redirects.py redirects.csv
# Test & deploy
git add go/ redirects.csv && git commit -m "Add redirect for Product Name" && git push
Bulk Update
# Edit CSV with multiple new products
nano redirects.csv
# Generate all redirects (overwrites existing)
python3 generate_redirects.py redirects.csv
# Review changes
git diff go/
# Deploy
git add go/ redirects.csv && git commit -m "Bulk update redirects" && git push
Testing Before Deploy
# Generate redirects
python3 generate_redirects.py redirects.csv
# Start local server
bundle exec jekyll serve
# Test in browser
open http://localhost:4000/go/yourslug/
# Should redirect to your affiliate link
π Troubleshooting
βFile not foundβ Error
# Make sure file exists
ls -la redirects.csv
# Check you're in the right directory
pwd
# Should show: /home/will/devops/th1nkn3st/site
βNo valid redirects foundβ
# Check CSV format (must have header row)
head -2 redirects.csv
# Should show:
# slug,affiliate_link,product_name
# anker67,https://amzn.to/4qhzGlu,Anker Prime 67W
# Check for required fields
cat redirects.csv | grep -v "^slug" | cut -d',' -f1,2
Redirect Not Working
# Rebuild Jekyll site
bundle exec jekyll clean
bundle exec jekyll build
# Check file was generated
ls -la _site/go/yourslug/
# Should show: index.html
π File Structure
site/
βββ generate_redirects.py # Generator script
βββ redirects.csv # CSV data source
βββ redirects.json # JSON data source (alternative)
βββ go/
βββ README.md # Documentation
βββ _template.html # Manual template
βββ anker67.html # Generated redirect
βββ logitechg305.html # Generated redirect
βββ samsungg9.html # Generated redirect
π Advanced Usage
Custom Output Directory
Edit script line 86 to change output location:
go_dir = Path(__file__).parent / 'go' # Change 'go' to your dir
Adding Custom Fields
Extend the template in REDIRECT_TEMPLATE variable and add fields to CSV/JSON.
Integration with CI/CD
# .github/workflows/generate-redirects.yml
- name: Generate redirects
run: python3 generate_redirects.py redirects.csv
- name: Commit changes
run: |
git add go/
git commit -m "Auto-generate redirects" || true
π Example Output
$ python3 generate_redirects.py redirects.csv
Reading CSV file: redirects.csv
Generating 3 redirect file(s)...
β Created: go/anker67.html β https://amzn.to/4qhzGlu
β Created: go/logitechg305.html β https://amzn.to/47b37wC
β Created: go/samsungg9.html β https://amzn.to/477v8VR
β
Successfully generated 3 redirect file(s)
Next steps:
1. Test locally: http://localhost:4000/go/<slug>/
2. Commit: git add go/ && git commit -m 'Add affiliate redirects'
3. Push: git push
4. Test live: https://www.th1nkn3st.com/go/<slug>/
π License
Part of the Th1nkN3st site project. For internal use.
Version: 1.0
Last Updated: October 16, 2025
Author: Th1nkN3st Team