This project showcases how to use Next.js with Blogger as the data source, implementing Incremental Static Regeneration (ISR). The blog allows pages to be statically generated and automatically regenerated with updated content from the server, making it ideal for blogs and sites that rely on dynamic content.
- Next.js with ISR: Utilizes Next.js's incremental static regeneration for real-time content updates.
- Blogger Feeds: The blog content is generated based on Blogger's Atom or RSS feeds. Make sure to enable and set your Blogger feed to "Full" to ensure all the content is available for the Next.js site.
- SEO-friendly: Easy configuration to control meta tags, such as
robots
, to allow or block content indexing. - Prevent Duplicate Content: It's recommended to disable your Blogger blog from search engine indexing to avoid duplicate content in Google and focus indexing efforts on the Next.js site.
- Easy deployment on Vercel: Perfect for deploying on platforms like Vercel.
To use this setup, you must enable the feed of your Blogger blog and set it to Full to provide complete article data.
- Go to your Blogger dashboard.
- Navigate to Settings > Other.
- Under Site Feed, ensure the feed is set to Full.
To prevent duplicate content from appearing on Google (both from Blogger and Next.js), it's highly recommended to disable the Blogger blog from being indexed by search engines:
-
Go to Settings > Search preferences.
-
Under Crawlers and indexing, turn Custom robots.txt on and provide a simple robots.txt that disallows all bots from indexing the Blogger site:
User-agent: * Disallow: /
This will ensure that only your Next.js site will be indexed, focusing traffic on your static site.
To run this project locally, you will need to set up some environment variables. Here’s an example of the variables required for production:
Create a .env.local
file in the root of the project with the following content:
# URL of your Blogger blog's feed (Atom or RSS)
BLOGGER_URL=https://www.miblogexample.com
# Control whether to index pages by search engines
ROBOT_NOINDEX=false
BLOGGER_URL
: The URL of your blog’s feed (you can use either the Atom feed or RSS feed).ROBOT_NOINDEX
: Controls whether pages should be indexed by search engines. Set totrue
to prevent indexing, orfalse
to allow indexing.
-
Clone this repository:
git clone https://github.com/pintoderian/isr-blog-nextjs-blogger.git
-
Install dependencies:
npm install
-
Configure the environment variables as indicated above.
-
Start the development server:
npm run dev
-
Open http://localhost:3000 to view the blog locally.
You can see a live demo here:
To deploy in production, you can use platforms like Vercel:
- Connect your repository to Vercel.
- Set up the production environment variables in Vercel's settings.
- Deploy, and your site will be live within minutes.