Custom format and pretty urls

hi
I am trying to customise the default output format to generate files with php extension so i can include some small snippets to customise my site.

I have followed the instructions and modified my config:

[mediaTypes]
[mediaTypes."text/html"]
suffixes = ["php"]
isHTML = true

[outputs]
home = [ "HTML"]

[outputFormats]
[outputFormats.HTML]
mediaType = "text/html"

It correctly generates files with php suffix, but I no longer get pretty urls eg localhost:1313/docs/first/index.php rather than localhost:1313/docs/first/

If i remove the config for custom outputs it works as expected. I have tried setting the basename in the config but it doesn’t do anything. Is there a way i can get pretty url’s generated?

I have creaded a simple demo at https://github.com/acraftydev/hugophp

thanks
Andrew

Have you tried creating a new mediaType for PHP. And then assign it to the HTML output format? Rather than editing the built in HTML mediaType

1 Like

hi yes i have tried creating a new media type and assigning it the html same result.

I think the reason maybe in “resources/page/page_paths.go”, func isHtmlIndex is hardcoded to check against the string ‘index.html’. I am not very familar with the hugo code so maybe completely wrong.

thanks

Do you have a repo for us to explore? I’m curious to try out a few things.

Hi got a basic example here:

thanks

Just tried some stuff. I personally think this should work and this might be a bug.
You should head to the repo and create a new issue.

i have created issue