How can I include PHP code in Hugo?

There’s two parts to your question:

  1. Can Hugo output php files?

Yes, if configured correctly.

  1. Will Hugo run the php code?

No. Unless you have server magic going on, but that is outside of Hugo.

Have you read through this topic?: Is it possible to use Hugo template functions and variables in a PHP file?

The first part we can probably help you with, but it will be easier if you had your code in a repo somewhere easily clone-able.

1 Like