diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index ed39c2459..fced4b47b 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -27,10 +27,12 @@ Add Answer example Here is an example of a very simple plugin that adds a "Hello World" into the answer area: +In ``searx/plugins`` create a file named ``hello_world.py`` with the following content: + .. code:: python from flask_babel import gettext as _ - from searx.plugins import Plugin + from searx.plugins import Plugin, PluginInfo from searx.result_types import Answer class MyPlugin(Plugin): @@ -44,6 +46,23 @@ answer area: def post_search(self, request, search): return [ Answer(answer="Hello World") ] +You will then need to add your new plugin in the :ref:`settings.yml` file like this: + +.. code:: yaml + + plugins: + ... + searx.plugins.hello_world.MyPlugin: + active: true + + +``searx.plugins.hello_world.MyPlugin`` is the Python import path of the new plugin we created. +``searx.plugins.hello_world`` represents the file path, while ``MyPlugin`` represents the name of the plugin class. + +If you don't want the plugin to be part of SearXNG's core (i.e. maintain it independently of SearXNG), +you may also place the file at any other path as long as you update the reference to it in :ref:`settings.yml`. +For more examples, see :ref:`settings external_plugins`. + .. _filter urls example: Filter URLs example