Prevent Hugo from modifying PHP code

Hi all!

I am trying to use PHP with Hugo—and read quite a lot here.

The ‘complicated’ stuff is working:

      - php
    mediaType: application/x-php
    isHTML: true
    baseName: index
    - PHP

But I cannot prevent Hugo from modifying the PHP code:

I tried

{{ readFile "file.php" | safeHTML }}

and various combinations of safeHTML, .RawContent, plainify, htmlUnescape

Any other idea?

Thanks in advance!

Put the php files under static/php. Hugo will copy it to /php.
To use it, create links to it. Don’t forget to config your web server to process php.

1 Like

Try adding to your PHP output format:

isPlainText: true

You sacrifice html template security, but as long as you trust your code, it may fix your issue.

1 Like

Thank you very, very much, guys!

Ok, now I get what the isPlainText setting is good for :wink: