2

I have to build two websites: one for the staging and another one for the production. and both are hosted on the server, but when I search on google with the website name, both websites are comes together, and the staging one comes before the production website, I just want that when I find the website by the name only the production one will come, I do not want to show my staging website to visitors. Both websites are built in the next.js. There would be any way to handle to SEO of the production website or reduce the rank of my staging website.

4
  • Do the production and staging sites use different host names (different domains or subdomains)? Jul 22 at 8:43
  • But I have already hosted the website and with the name- XYZ-staging.com and xyz.com, so now how what I can do for this ... Jul 22 at 9:23
  • 1
    Can't you just ban google bot in your robots.txt file Jul 22 at 9:43
  • Does it also affect the production site ?? Jul 22 at 10:16

1 Answer 1

2

Long-term solution

(Assuming you are using Apache. Equivalent solutions exist for other web servers.) Any of these solutions is fine:

  1. Use htpasswd to only expose the website to users with the credentials.
  2. Use the htaccess to limit access to the staging site to a specific IP range.
  3. Use the htaccess to limit access to a specific user agent. Use a browser plugin to change your user agent to this specific one.

These three solutions are all good for privacy and security. You will probably not want anybody to just click around on your staging site. And all three solutions prevent Google bot from crawling your site.

Pick the solution that best fits your use case. If you do not have a static IP address or have a lot of coworker and stakeholders who need access to the staging site, some of these solutions might not be very convenient for you.

Short-term solution

Since Google already indexed your site, you should first do this:

  1. Authenticate your staging site in Google Search Console.
  2. In Google Search Console, manually remove the URLs that Google Bot has crawled so far from the Google Index.
  3. Add the robots-noindex meta tag to all documents on the staging site. That means the next time Google crawls them, they will be removed from the index.

In theory, step 3 alone would be enough. Steps 1 and 2 just help to speed up the process.

Once Google has no more pages of your staging site in the index (or only has them in the index without any content, saying "No information is available for this page."), activate one of the long-term measures.

If none of the long-term solutions work, you could, in theory, stick with having robots-noindex everywhere on the staging site. Google would never show the site in search results. However, your competitors or hackers might find it.

Additional concerns

  1. Make sure the robots-noindex from the staging site never make it to the production site. You would - temporarily - lose all your Google rankings.
  2. Make sure there are no links from your production site to the staging site. You should crawl the production site with a tool like Screamign Frog and make sure all links, canonical, hreflang, alt, etc., always go to the production site and never to the staging site.
1
  • 1
    It sounds like part of the question is how do you use the same code for both production and staging while keeping Google back just off just the staging site Jul 23 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.