4

I've created a page on read-the-docs that I would like to add in Google inspection for indexing. https://ltb-symm.readthedocs.io/

In URL Inspection Tool explains one way to prove the ownership of the page is to add meta tag in the <head> section of your page

I am using sphinx when compiling .rst files into HTML, so I tried to use

.. raw:: html 
<meta name="google-site-verification" content="***" />

In the .rst file, but after compiling it inserts the tag in the body section not the head section.

What to do that sphinx would insert the tag in the head section?

2
  • You don't "put pages on Google." You make pages available publicly, link to them from somewhere else, and Googlebot crawls them then decides whether or not they should be indexed. A three week old site is almost never going to get indexed. New sites need 6 months to a year. Commented May 27, 2023 at 10:32
  • 2
    As far as Google search console verification goes, you should be able to use the meta tag verification. This site was having problems initially but reported that the got it ot work. support.google.com/webmasters/thread/103508537/… Commented May 27, 2023 at 10:36

3 Answers 3

3

if you're trying to add that Google Search Console verification meta tag to your Read the Docs page using Sphinx, your current method with .. raw:: html isn't gonna cut it because it puts the tag in the body, not in the head section.

What you really want to do is tweak the conf.py file in Sphinx to get that meta tag exactly where you need it. And if you're having trouble, don't forget you can also verify using the URL Prefix method in Google Search Console.

Here's a little snippet for conf.py:

def setup(app):
app.add_config_value('google_site_verification', '', 'html')

def add_google_tag(app, pagename, templatename, context, doctree):
    metatag = '<meta name="google-site-verification" content="your-verification-code" />'
    context['metatags'] = context.get('metatags', '') + metatag

app.connect('html-page-context', add_google_tag)

This will make sure your meta tag lands right in the head section across all your pages.

2

You can add your ReadTheDocs documentation to Google Search Console even if you don’t own the domain. This can be done via the “URL prefix”. Use the meta tag method with the metadata directive (https://docutils.sourceforge.io/docs/ref/rst/directives.html#meta) to your ‘root’ index.rst file:

.. meta::
   :google-site-verification: <your code>
-1

Search Console isn't going to let you verify a page, it only verifies domains. And you don't own that domain.

1
  • 2
    It looks like a subdomain to me, you can verify subdomains Commented Jun 2, 2023 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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