DEV Community

Cover image for Looking for an easy way to request Google Search Console to index your website pages?
Ismael Garcia
Ismael Garcia

Posted on

Looking for an easy way to request Google Search Console to index your website pages?

Looking for an easy way to request Google Search Console to index your website pages?

Here is how a handle the request to index all the 764 pages from https://must-know-resources-for-programmers.giessen.dev/.

  1. Local project and folder
    1. pnpm init
    2. pnpm add google-indexing-script
    3. Update the package.json scripts "seo": "node index.js"
    4. touch index.js
    5. add the following to the index.js file
import { index } from "google-indexing-script";
import serviceAccount from "./service_account.json" assert { type: "json" };

index("<WEBSITE_URL_HERE>", {
  client_email: serviceAccount.client_email,
    private_key: serviceAccount.private_key,
  quota: {
    rpmRetry: true
  }
})
  .then(console.log)
  .catch(console.error);

Enter fullscreen mode Exit fullscreen mode
  1. Follow the steps in the https://github.com/goenning/google-indexing-script?tab=readme-ov-file#preparation
  2. Download the credentials JSON https://github.com/goenning/google-indexing-script/issues/2
  3. Rename the download JSON and move to the folder where the index.js is located at
  4. Go to Google Search Console
    1. Select the Website to index
    2. Go to settings
    3. Users and permissions
    4. Add user
    5. Add the email from the <username@project>.iam.gserviceaccount.com that you created in the step 6 preparations
    6. In the permissions, Select Owner
  5. Now you can run the pnpm seo in the terminal and that should make the request to index all the pages that are in the sitemap of your website

Top comments (0)