I have a PHP contact form, which currently resides in
/static/contact.php file. Keeping it up to date with changes that I commit to my theme is very inconvenient, because whenever I modify something in
layouts, I need to manually propagate the change to
contact.php. And usually I miss a thing or two.
contact.php loads two external
.html files (with
include statement), which are located outside of my Apache public path:
contact-form.htmlstores layout of the contact form,
contact.phpto display appropriate message about mail delivery status (sent or failed)
/contact/ URL is redirected to
RewriteRule, so there’s no markdown involved at all.
Is it somehow possible to take advantage of Hugo’s template functions and variables in PHP files? Ideally, I’d like the contact form to use my
layouts/_default/baseof.html — load
footer.html partials and execute
I tried putting a test PHP file in
/assets, but when Hugo is building the website, it seems to be ignoring any PHP files from that path.