mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#36 add Google Search how-to to FAQ
This commit is contained in:
parent
cafc522f54
commit
d5aa1c6ccc
30
doc/faq.rst
30
doc/faq.rst
@ -119,6 +119,36 @@ Google Analytics
|
|||||||
{% endblock %}
|
{% 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
|
.. _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
|
.. _xhtml to reST: http://docutils.sourceforge.net/sandbox/xhtml2rest/xhtml2rest.py
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user