Content is user-generated and unverified.

WordPress to Hugo Migration Guide

Phase 1: Export and Prepare Data

Step 1: Export WordPress Content

  1. Access your WordPress admin panel at https://dushyant.ahuja.ws/wp-admin/
  2. Go to Tools → Export
  3. Select "All content" and click Download Export File
  4. This creates an XML file with all your posts, pages, comments, and metadata

Step 2: Download Media Files

  1. Via FTP/cPanel:
    • Connect to your current hosting
    • Navigate to /wp-content/uploads/
    • Download the entire uploads folder
  2. Alternative - Plugin method:
    • Install "Export Media Library" plugin
    • Export all media files as a zip

Step 3: Set Up Local Development Environment

bash
# Install Hugo (choose your OS)
# Windows (with Chocolatey)
choco install hugo-extended

# macOS (with Homebrew)
brew install hugo

# Linux (Ubuntu/Debian)
sudo apt-get install hugo

# Verify installation
hugo version

Phase 2: Create Hugo Site Structure

Step 4: Initialize Hugo Site

bash
# Create new Hugo site
hugo new site dushyant-blog
cd dushyant-blog

# Initialize git repository
git init

Step 5: Choose and Install a Theme

bash
# Example with popular themes (choose one)
# Option 1: PaperMod (clean, fast)
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod

# Option 2: Ananke (Hugo default)
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

# Option 3: Mainroad (blog-focused)
git submodule add https://github.com/Vimux/Mainroad.git themes/Mainroad

Step 6: Configure Hugo

Create/edit config.yaml:

yaml
baseURL: 'https://dushyant.ahuja.ws'
languageCode: 'en-us'
title: "Dushyant's thoughts"
theme: 'PaperMod'  # or your chosen theme

params:
  author: 'Dushyant'
  description: 'Personal blog and project showcase'
  
menu:
  main:
    - name: 'Home'
      url: '/'
      weight: 10
    - name: 'Posts'
      url: '/posts/'
      weight: 20
    - name: 'Categories'
      url: '/categories/'
      weight: 30

taxonomies:
  category: categories
  tag: tags

Phase 3: Convert WordPress Content

Step 7: Convert Posts Using wordpress-to-hugo-exporter

bash
# Install the converter
npm install -g wordpress-export-to-markdown

# Convert your WordPress export
wordpress-export-to-markdown --input=your-export.xml --output=content/posts

# Alternative: Manual Python script approach
pip install python-frontmatter markdown

Step 8: Manual Content Cleanup

After conversion, you'll need to:

  1. Review each post in content/posts/
  2. Fix image paths - update WordPress URLs to local paths
  3. Adjust frontmatter format:
yaml
---
title: "The Discworld Table"
date: 2025-08-19T00:00:00Z
categories: ["Personal", "Projects"]
tags: ["3d-printing", "discworld"]
draft: false
---

Step 9: Organize Media Files

bash
# Create static directory structure
mkdir -p static/images
mkdir -p static/uploads

# Copy your WordPress uploads
cp -r /path/to/wp-uploads/* static/uploads/

# Update image references in posts
# Change: https://dushyant.ahuja.ws/wp-content/uploads/2025/08/image.jpg
# To: /uploads/2025/08/image.jpg

Phase 4: Local Testing

Step 10: Test Locally

bash
# Build and serve locally
hugo server -D

# Visit http://localhost:1313 to preview
# Check all pages, images, and navigation work correctly

Step 11: Content Adjustments

  • Fix broken links and images
  • Customize theme if needed
  • Add any missing pages (About, Contact, etc.)
  • Set up proper redirects for changed URLs

Phase 5: VPS Setup and Deployment

Step 12: Prepare VPS

bash
# SSH into your VPS
ssh user@your-vps-ip

# Update system
sudo apt update && sudo apt upgrade -y

# Install nginx
sudo apt install nginx -y

# Install certbot for SSL
sudo apt install certbot python3-certbot-nginx -y

# Optional: Install git for deployment
sudo apt install git -y

Step 13: Configure Nginx

Create /etc/nginx/sites-available/dushyant.ahuja.ws:

nginx
server {
    listen 80;
    server_name dushyant.ahuja.ws www.dushyant.ahuja.ws;
    root /var/www/dushyant.ahuja.ws;
    index index.html;

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    location / {
        try_files $uri $uri/ =404;
    }

    # Cache static assets
    location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

Step 14: Enable Site and SSL

bash
# Enable the site
sudo ln -s /etc/nginx/sites-available/dushyant.ahuja.ws /etc/nginx/sites-enabled/

# Test nginx configuration
sudo nginx -t

# Restart nginx
sudo systemctl restart nginx

# Get SSL certificate
sudo certbot --nginx -d dushyant.ahuja.ws -d www.dushyant.ahuja.ws

Step 15: Deploy Hugo Site

bash
# Build the site locally
hugo --minify

# Upload to VPS (from your local machine)
rsync -avz --delete public/ user@your-vps:/var/www/dushyant.ahuja.ws/

# Or set up git-based deployment on VPS
sudo mkdir -p /var/www/dushyant.ahuja.ws
sudo chown $USER:$USER /var/www/dushyant.ahuja.ws
git clone your-repo-url /var/www/dushyant.ahuja.ws-source
cd /var/www/dushyant.ahuja.ws-source
hugo --minify -d /var/www/dushyant.ahuja.ws

Phase 6: Final Steps

Step 16: Update DNS

  • Update A records to point to your VPS IP
  • Wait for DNS propagation (up to 48 hours)

Step 17: Set Up Automation (Optional)

Create a deploy script /home/user/deploy.sh:

bash
#!/bin/bash
cd /var/www/dushyant.ahuja.ws-source
git pull origin main
hugo --minify -d /var/www/dushyant.ahuja.ws
sudo systemctl reload nginx

Step 18: WordPress Redirects

To maintain SEO, set up redirects from old WordPress URLs:

nginx
# Add to your nginx config
location ~ ^/\d{4}/\d{2}/\d{2}/(.+)/?$ {
    return 301 /posts/$1/;
}

location /category/ {
    return 301 /categories/;
}

Post-Migration Checklist

  • All posts migrated correctly
  • Images display properly
  • Categories and tags work
  • RSS feed available at /index.xml
  • SSL certificate installed
  • Site loads quickly
  • Mobile responsive
  • Search engines can crawl
  • Old URLs redirect properly
  • Backup procedures in place

Maintenance Tips

  1. Regular backups of your Hugo source code
  2. Automated deployments via git hooks
  3. Monitor SSL certificate renewal
  4. Keep Hugo updated for security
  5. Use CDN for better global performance (optional)

Troubleshooting Common Issues

  • Images not loading: Check file paths and permissions
  • Site not updating: Clear browser cache, verify deployment
  • SSL issues: Run sudo certbot renew --dry-run
  • Performance: Enable gzip, optimize images, use CDN
Content is user-generated and unverified.
    WordPress to Hugo Migration Guide | Claude