#36 add Google Search how-to to FAQ

This commit is contained in:
Timotheus Kampik 2019-02-24 23:03:49 +01:00
parent cafc522f54
commit d5aa1c6ccc

View File

@ -119,6 +119,36 @@ Google Analytics
{% endblock %}
Google Search
To replace Sphinx's built-in search function with Google Search, proceed as
follows:
1. Go to https://cse.google.com/cse/all to create the Google Search code
snippet.
2. Copy the code snippet and paste it into ``_templates/searchbox`` in your
Sphinx project:
.. code-block:: html+django
<div>
<h3>{{ _('Quick search') }}</h3>
<script>
(function() {
var cx = '......';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
3. Add ``searchbox.html`` to the :confval:`html_sidebars` configuration value.
.. _api role: https://git.savannah.gnu.org/cgit/kenozooid.git/tree/doc/extapi.py
.. _xhtml to reST: http://docutils.sourceforge.net/sandbox/xhtml2rest/xhtml2rest.py