-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CLI command (hugo render
) for printing the source files in a custom format
#10924
Comments
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Note: Someone with a better knowledge of the English language should edit this title, its intent isn't that clear right now. Thanks.
Problem
As of today, there's no "official" way for rendering the list of pages in another format as CSV.
hugo list all
renders all pages just fine, it's just very limited, as there's no configuration for the output, access to the params, etc.Parsing the CSV is possible, but due to the mentioned problems, not suitable for all solutions.
We can render the pages in any format using
resources.FromString
andresources.ExecuteAsTemplate
as described in the forum. However, this has the downside that we need to generate the whole page, even if we just want a single file. Especially with a lot of pages, image hooks, etc. this can take a lot of time.Proposal
Other Go-based tools, for example
kubectl
allow to pass a Go Template string which is used for rendering the output. I'd like to propose such a feature to the Hugo CLI as well. It would allow to render the pages/resources/whatever in any format.A possible CLI implementation might look like this:
$ hugo render "<some Go Template syntax>"
or
$ hugo render < my-template.tmpl
Scenarios
This is useful for the following scenarios:
Rendering a
.htaccess
Contents of
htaccess.tmpl
:Validating that each page has a title
Contents of
validate.tmpl
:Benefits
--renderToMemory
Risks
I can't see any risks at the moment.
The text was updated successfully, but these errors were encountered: