How to include an image in an HTML page served dynamically by Prolog?

It's true that's not simple to solve your problem. Please read carefully this 'how to' page, section Serving many 'server support' files.

Here is the code I tested:

http:location(images, root(images), []).
user:file_search_path(icons, '/home/carlo/prolog').
:- http_handler(images(.), serve_files_in_directory(icons), [prefix]).

and the HTML that uses that resources

intro -->
    html([p(ol([li('select a path'),
            li('scan resources from it'),
            li('RDF-ize them'),
            li('browse with foldable SVG')
           ])),
          \sep,
          'png before', img(src='images/swipl.png'), 'png after',
          \sep,
          'jpeg before', img(src='/images/swipl.jpeg'), 'jpeg after'
         ]).

I note that both specifications img(src='images/swipl.png') and img(src='/images/swipl.jpeg') work, and this 'feature' contributes to blurry the interface behaviour.

Here the output

enter image description here

HTH