Can I use dynamic PHP in Hugo site layout?

Hi,

Please don’t flame me, as I know the idea of using dynamic PHP in a static site generator goes against the premise of it being ‘static’, but …

I was just wondering if dynamic PHP could be used in the layout of the page, e.g. using includes/header.php for example.

Thanks
Avery

Not stupid at all.

Currently I would say it’s not possible out of the box, as you would need the files with a PHP extension.

With this in place it will be simple:

Hi,

Thanks for getting back to me so quickly! I followed the convo and found a new thread dealing with the issue here: http://discuss.gohugo.io/t/discussion-for-configurable-file-extension-320/157

Unfortunately there are no replies and the thread started over a year ago…

Loosely related question: Is it possible to use .php files once the blog has been deployed? (e.g. drop them in place once Hugo blog has been sent to a server?)

Thanks
Avery

  1. You can put PHP files in /static (irony) – they can be put in /content, too, I guess – as they will just be copied.
  2. As to PHP file extension, I guess a current workaround would be to add a post build step with a shell script or similar that replaces all html => php.

Yes, it’s a dusty past-its-sell-by-date thread, but must mention that you can drop some PHP into the the middle of a Hugo project – see this page.