NewFirst month of Starter or Pro for $1Your first month of Starter or Pro for just $1, then cancel anytimeSee pricing
Ranken logoRanken.io

Add a blog to Next.js at /blog

The short answer

To add a blog to a Next.js site at /blog, add two rewrites to next.config.js that send /blog and everything under it to Ranken, then deploy. Every other route of your app stays as it is, and the blog loads on your own domain with no middleware or API route.

Method
A rewrite in next.config.js
Time
About 2 minutes
You need
Access to your Next.js code
Ranken plan
Starter or Pro
yoursite.com/blog
/blog/*next.configRanken blog
/*Next.js site
Only /blog goes to Ranken. Every other page keeps working on Next.js, on the same domain.

How do I add a blog to Next.js?

Create your blog in Ranken and choose a /blog subfolder, then follow these steps. The examples use www.yoursite.com/blog. Your dashboard shows the same steps with your own address filled in, plus a prompt you can paste into an AI coding assistant.

  1. 1

    Add the rewrite to next.config

    Merge it into your existing config. beforeFiles lets the blog win over any page at the same path.

    next.config.js
    module.exports = {
      async rewrites() {
        return {
          beforeFiles: [
            { source: "/blog", destination: "https://proxy.ranken.blog/your-blog" },
            { source: "/blog/:path*", destination: "https://proxy.ranken.blog/your-blog/:path*" },
          ],
        };
      },
    };
  2. 2

    Deploy

    Push and let your hosting rebuild.

On Vercel the rewrite runs at the edge, with no extra function.

What should you check before you start?

  • beforeFiles makes the rewrite win over any page or route you already have at /blog. Move an old /blog route first if you want to keep it.
  • If rewrites() already returns an array, turn it into { beforeFiles, afterFiles } and keep your existing rules.

Why put your Next.js blog at /blog instead of a subdomain?

A subfolder keeps every article on your main domain, so the links and authority each post earns build up in one place, next to your product or store pages. A subdomain such as blog.yoursite.com works too, but search engines can treat it more like a separate site. Ranken supports both, plus a custom domain.

Next.js blog questions

Do I need middleware or an API route?

No. A rewrite in next.config is enough. On Vercel it runs at the edge, so there is no function to pay for or maintain.

Does it work with the App Router and the Pages Router?

Yes. Rewrites live in next.config and work the same way for both routers.

Add a blog to another platform

Steps checked . See all integrations

Your Next.js site, now with a blog that ranks

Ranken hosts the blog at /blog with SEO, schema, llms.txt and one-click indexing built into every post.