Firebase Setup Guide
One-time setup. Takes about 10 minutes. Do this before going live.
Create a Firebase Project
Firebase is Google's free cloud database. It stores all your blog posts, subscribers, and messages online so everyone can see them.
- Go to console.firebase.google.com and sign in with a Google account.
- Click "Add project" → name it
mnh-blog(or anything you like). - Disable Google Analytics for now (you can add it later) → Click "Create project".
- Wait ~30 seconds for Firebase to set up your project.
Enable Firestore Database
Firestore is the cloud database where posts, subscribers and messages are stored.
- In your Firebase project, click "Firestore Database" in the left sidebar.
- Click "Create database".
- Choose "Start in test mode" (we will add security rules in Step 5).
- Select a region close to India (e.g.,
asia-south1— Mumbai) → Click "Enable".
Enable Email/Password Authentication
This lets you log in to the admin panel securely. Only you know the password — it is never stored in the code.
- Click "Authentication" in the left sidebar → "Get started".
- Under Sign-in providers, click "Email/Password" → Enable the first toggle → "Save".
- Click the "Users" tab → "Add user".
- Enter your email address and a strong password → "Add user".
- This email and password is what you use to log in to the admin panel.
Copy Your Firebase Config into js/config.js
This links your website to your Firebase project.
- Click the gear icon ⚙️ next to "Project Overview" → "Project settings".
- Scroll down to "Your apps" → Click the web icon
</>→ Register app (name:mnh-blog). - You will see a
firebaseConfigobject. Copy the values from it. - Open the file
js/config.jsin your code editor and paste the values replacing the placeholder text.
The file should look like this after you fill it in:
const firebaseConfig = {
apiKey: "AIzaSy...",
authDomain: "mnh-blog.firebaseapp.com",
projectId: "mnh-blog",
storageBucket: "mnh-blog.appspot.com",
messagingSenderId: "1234567890",
appId: "1:1234567890:web:abc123"
};
Set Firestore Security Rules
These rules make sure:
- Anyone can read your blog posts (required for visitors to see them)
- Only you (logged-in admin) can create, edit, or delete posts
- Anyone can submit a newsletter signup or contact message
- Only you can read subscriber emails and contact messages
In Firebase Console → Firestore Database → Rules tab, replace the existing rules with this:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Blog posts: public read, admin write
match /posts/{postId} {
allow read: if true;
allow create, update, delete: if request.auth != null;
}
// Newsletter subscribers: public create, admin read/delete
match /subscribers/{subId} {
allow create: if true;
allow read, delete: if request.auth != null;
}
// Contact messages: public create, admin read/delete
match /messages/{msgId} {
allow create: if true;
allow read, delete: if request.auth != null;
}
}
}
Click "Publish" to save the rules.
Deploy Your Website
Upload all the website files to any static hosting provider. Recommended free options:
Drag & drop the folder at netlify.com
Push to GitHub, enable Pages in settings
Free CDN, fast globally, easy setup
Add Authorized Domains (Important)
Firebase needs to know which domains are allowed to use your database. Without this, login will fail on your live domain.
- Firebase Console → Authentication → Settings tab → Authorized domains.
- Click "Add domain" and add your live website domain (e.g.,
manjunathswamynh.comor your Netlify URL likeyoursite.netlify.app). localhostis already there for local testing.
Seed Your First Posts
After logging into the admin panel on your live site, the Dashboard will show a "Seed Sample Posts" button if your blog is empty. Click it to load 9 sample articles across all categories — Trading, Books, Trips, and Cooking. You can edit or delete them anytime.
How to Manage Your Blog Day-to-Day
➕ Add a new post
Admin Panel → New Post → pick category, write your article, click "Publish Live". Done — visible to everyone instantly.
✏️ Edit an existing post
Admin Panel → All Posts → click the pen icon ✏️ next to any post → make changes → click "Update Live".
🗑️ Delete a post
Admin Panel → All Posts → click the trash icon 🗑️ → confirm. Post is permanently removed from your blog for all visitors.
👥 View subscribers
Admin Panel → Subscribers. Export as CSV to send newsletters via Gmail, Mailchimp, or any email tool.