Skip to content
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

Ability to create pages dynamically? #140

Closed
gkostyanikov opened this issue Nov 25, 2013 · 22 comments
Closed

Ability to create pages dynamically? #140

gkostyanikov opened this issue Nov 25, 2013 · 22 comments

Comments

@gkostyanikov
Copy link

Using this feature provided by Middleman http://middlemanapp.com/dynamic-pages/ quite often. So maybe somebody will point me to the machinery of doing similar stuff in Hugo or consider adding this feature in future releases?


Edit: New link at https://middlemanapp.com/basics/dynamic-pages/

@spf13
Copy link
Contributor

spf13 commented Nov 25, 2013

I think I understand the feature, but not the use case. What do you use it for?

Best,
Steve

-- 
Steve Francia
http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On November 25, 2013 at 6:35:47 AM, gkostyanikov ([email protected]) wrote:

Using this feature provided by Middleman http://middlemanapp.com/dynamic-pages/ quite often. So maybe somebody will point me to the machinery of doing similar stuff in Hugo or consider adding this feature in future releases?


Reply to this email directly or view it on GitHub.

@gkostyanikov
Copy link
Author

I'm using it for generating tens of thousands pages when most of the data comes from db.

@cryptix
Copy link
Contributor

cryptix commented Dec 3, 2013

I also need to fill static pages with data from a db (large tables mostly) so I began to hack on that part on my fork here.

My main problem with the approach I chose is that the data formats and queries are hardcoded in hugolib/db.go. So to use this an enduser would have to maintain a fork of hugo.

Simple query strings could go into the frontmatter but what bugs me more is that I don't know how to construct the types for the returned rows to scan into at runtime. I'm not sure it's possible at all because of go's static typing but maybe there is some kind of dark reflection magic i'm not aware of, yet? Another option would be to boil every column down to a string but than you would loose a lot of options (like using .Format on time.Time objects)..

@spf13
Copy link
Contributor

spf13 commented Dec 3, 2013

See how we parse config and front matter data from json, toml & yaml. It should provide a good example of reflection.

@christopher-haueter
Copy link

+1. This would be an amazing feature.

@SchumacherFM
Copy link
Contributor

Here is an implementation of one solution on a per page basis:

http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/

I need some more tipps from the hugo core team to create hugo idiomatic code.

@spf13
Copy link
Contributor

spf13 commented Dec 21, 2014

I really like this idea of an approach.

@bep
Copy link
Member

bep commented Dec 21, 2014

+1 Very, very nice. Esp. the remote feature. One concern to think about here is maybe add some kind of cache ... I would hate for my livereload to have to wait for hundreds of remote resources to finish.

@anthonyfok
Copy link
Member

Update: @SchumacherFM has submitted a wonderful Pull Request #748: "Feature: GetJson and GetJson in short codes or other layout files" as a solution to this issue.

@bep
Copy link
Member

bep commented Jul 25, 2015

We now have both Data Files and Data driven content -- this is as dynamic as one would get for a static site.

@bep bep closed this as completed Jul 25, 2015
@lukasz-kaniowski
Copy link

Hi guys,
I'm trying to generate a list of book description pages from a json that contains a list of them, i.e:

[
  { "title", "book A", "description": "description A"},
  { "title", "book B", "description": "description B"},
  { "title", "book C", "description": "description C"}
] 

I would like to get 3 pages with details of given book (generated using same layout). Is that possible?

@bep
Copy link
Member

bep commented Nov 2, 2015

@lukasz-kaniowski not with Hugo alone ...

@lukasz-kaniowski
Copy link

@bep any recommendations? I'm creating this json file using node scrapper so I can change the sctructure, i.e. devide it into single json file per book. will this help?

@bep
Copy link
Member

bep commented Nov 2, 2015

@lukasz-kaniowski no, you would need to create a script outside Hugo to generate the content pages.

@lukasz-kaniowski
Copy link

@bep bummer. thanks for your help.

@SchumacherFM
Copy link
Contributor

Here is your solution:

http://cyrillschumacher.com/2015/02/09/virtual-pages-with-gohugo.io/

I never made a PR with this feature. It needs more love => Refactoring and hooking into other internal hugo stuff ...

Edit: Source => SchumacherFM@0f32b37

@lukasz-kaniowski
Copy link

@SchumacherFM nice one. i will have a go with it.

@SchumacherFM
Copy link
Contributor

Good luck.

@kpym
Copy link

kpym commented May 13, 2017

Why is this issue closed ? Is it because there is no hope to see pages generated for each record in a data set ? Or is it because this was implemented in some way since 2015 ?

If this was not done already I want to advocate for this feature.

@DanailMinchev
Copy link

DanailMinchev commented Sep 22, 2017

@bep @spf13
Could you confirm for clarity please:

There is no way to generate dynamic page currently in Hugo out of the box and it will not be implemented?

Details:
Perfect example of dynamic page will be https://middlemanapp.com/basics/dynamic-pages/ as pointed by @gkostyanikov
There is one workaround mentioned here: https://cyrillschumacher.com/2015/02/09/virtual-pages-with-gohugo.io/ by @SchumacherFM (thanks @SchumacherFM ), but this solution does not include adding any dynamic data to the Front Matter ( @SchumacherFM please correct me if I am wrong).
Basically, what I want is to generate dynamic pages using data from remote JSON API or any other datasource / I can generate static json files as well, but to be able fully control generated pages like url, title, taxonomies or any data parameters which should be rendered as part of the content.

It will be very useful for me if you clarify that.

THANKS

@kidsil
Copy link

kidsil commented Jul 18, 2019

So this thing has been bugging me for a while now (especially as I wanted to make it easier for contributors on my website to add content without manually creating folders & files).
So I wrote a temporary solution: kidsil/hugo-data-to-pages

It's a JS wrapper that generates pages from data (and it cleans after itself!).
I'm currently using this to generate pages from YAML files and it seems to be working perfectly.
Would definitely appreciate some feedback.

Cheers

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests