[docs] indicate modification of settings.yml is necessary to add new … (#6685)

* [docs] indicate modification of settings.yml is necessary to add new plugin + small exemple code correction
* [docs] plugins: add more details about adding new plugins
This commit is contained in:
Crizomb
2026-09-22 09:13:02 +02:00
committed by GitHub
parent df67eb6c26
commit b3c3895294

View File

@@ -27,10 +27,12 @@ Add Answer example
Here is an example of a very simple plugin that adds a "Hello World" into the Here is an example of a very simple plugin that adds a "Hello World" into the
answer area: answer area:
In ``searx/plugins`` create a file named ``hello_world.py`` with the following content:
.. code:: python .. code:: python
from flask_babel import gettext as _ from flask_babel import gettext as _
from searx.plugins import Plugin from searx.plugins import Plugin, PluginInfo
from searx.result_types import Answer from searx.result_types import Answer
class MyPlugin(Plugin): class MyPlugin(Plugin):
@@ -44,6 +46,23 @@ answer area:
def post_search(self, request, search): def post_search(self, request, search):
return [ Answer(answer="Hello World") ] 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:
Filter URLs example Filter URLs example