# Indexing Setup & Usage Guide This guide explains how to fast-track your content indexing on **Google** and **Bing/Yandex** using the provided scripts. > [!IMPORTANT] > **WAIT UNTIL LIVE:** Do not run these scripts until your new URLs are live and returning a `200 OK` status. If you submit a `404` URL, it may negatively impact your crawling budget or cause errors. --- ## 1. Google Indexing API The Google Indexing API allows you to notify Google when pages are added or removed. It is faster than waiting for the Googlebot to crawl your sitemap. ### Prerequisites: `service_account.json` To use the script `scripts/trigger-indexing.js`, you need a **Service Account Key** from Google Cloud. 1. **Go to Google Cloud Console:** [https://console.cloud.google.com/](https://console.cloud.google.com/) 2. **Create a Project:** (e.g., "QR Master Indexing"). 3. **Enable API:** Search for "Web Search Indexing API" and enable it. 4. **Create Service Account:** * Go to "IAM & Admin" > "Service Accounts". * Click "Create Service Account". * Name it (e.g., "indexer"). * Grant it the "Owner" role (simplest for this) or a custom role with Indexing permissions. 5. **Create Key:** * Click on the newly created service account email. * Go to "Keys" tab -> "Add Key" -> "Create new key" -> **JSON**. * This will download a JSON file. 6. **Save Key:** * Rename the file to `service_account.json`. * Place it in the **root** of your project (same folder as `package.json`). * **NOTE:** This file is ignored by git for security (`.gitignore`), so you must copy it manually if you switch laptops. 7. **Authorize in Search Console:** * Open the JSON file and copy the `client_email` address. * Go to **Google Search Console** property for `qrmaster.net`. * Go to "Settings" > "Users and permissions". * **Add User:** Paste the service account email and give it **"Owner"** permission. (This is required for the API to work). ### How to Run 1. **Run the script:** ```bash npm run trigger:indexing ``` *(Or manually: `npx tsx scripts/trigger-indexing.ts`)* 2. The script will automatically fetch ALL active URLs from the project (including tools and blog posts) and submit them to Google. You should see a "Success" message for each URL. --- ## 2. IndexNow (Bing, Yandex, etc.) IndexNow is a protocol used by Bing and others. It's much simpler than Google's API. ### Prerequisites: API Key 1. **Get Key:** Go to [Bing Webmaster Tools](https://www.bing.com/webmasters) or generate one at [indexnow.org](https://www.indexnow.org/). 2. **Verify Setup:** * The key is typically a long random string (e.g., `abc123...`). * Ensure you have a text file named after the key (e.g., `abc123....txt`) containing the key itself inside your `public/` folder so it's accessible at `https://www.qrmaster.net/abc123....txt`. * Alternatively, set the environment variable in your `.env` file: ``` INDEXNOW_KEY=your_key_here ``` ### How to Run This script (`scripts/submit-indexnow.ts`) automatically gathers all meaningful URLs from your project (tools, blog posts, main pages) and submits them. 1. Run the script: ```bash npm run submit:indexnow ``` *(Or manually: `npx tsx scripts/submit-indexnow.ts`)* 2. It will output which URLs were submitted. --- ## Summary Checklist - [ ] New page is published and live. - [ ] `service_account.json` is in the project root. - [ ] Service Account email is added as Owner in Google Search Console. - [ ] Run `npm run trigger:indexing` (for Google). - [ ] Run `npm run submit:indexnow` (for Bing/Yandex).