Converting only last .md created file, not all stored files in /post directory?

Is there a way to convert only the last .md file (based on its timestamp, metadata) or somehow by defining that file with a switch: --file?

No, that is not possible, but you can use last and other template functions to filter the posts to show. Se the documentation.

Why not?! What’s the philosophy behind it, is it a technical limitation for SSGs?

It is a pretty special use case, I have no idea what you need it for. So nothing like it is implemented – we implement what we need, not every permutation of what every person in the universe may need at some point in the future.

So, it’s possible, but not implemented.

If you are worried about speed, Hugo doesn’t have that problem (yet). With my Octopress blog, it took a while to do regeneration which was painful especially when I was editing posts. With Hugo the update is usually finished by the time I look at my second screen showing the browser.

1 Like

If you are worried about speed,

Yep, I was thinking of future of a big-scale production site!

It is a pretty special use case,

I don’t think so! I’m curious why a full rendering on all posts to add just a new post to website! This is a philosophical matter of your processing model on posts that I asked for. It’s not my personal case as a lonely guy in the universe :stuck_out_tongue: Just to know your philosophy behind this method?!

@michael_henderson, Sorry, I forget to tag threads. I’ll try to do it right.

Hugo is so fast that it does not need to have that sort of function.

OK, I think I understand the question now. It took some time. You talk about “only converting the changed Markdown file” …

In Hugo 0.16-DEV there is something like this:

In hugo server (watch mode): If you change a MD-file, only that file gets read from disk and converted, but then the entire site is rendered.

I see where you are coming from. However, it’s not as simple as just rendering the last .md file. Your newest post may not just appear in the first page to only need a regeneration of the first page and that post.

Suppose you have a recent posts section that appears in the sidebar like my website. When a new post is added, every page needs to be regenerated to add the new post. Or reference links.

In your case a static website generator could have a list of dependencies for each page. If any of the dependencies change, then the page needs to be regenerated. However, that gets too complicated and it’s just easier to regenerate the whole site from scratch.

1 Like

But what you want has been discussed, and will happen at some point, but it is, as @parsiya says, a very complex problem to solve in simple way.

  • Also, if you add tags to a post, Hugo will have to create pages for each new tag and edit the pages for existing tags.

  • Also, If your new post would cause a new page to be required for pagination purposes, then the pagination code would have to be rerun to regenerate that menu

…and there are probably more we’ve not thought of. It’s a bit like the Butterfly Effect, so it’s probably safest just to rebuild the whole thing each time.

As others have said, I wouldn’t worry about the speed issue. Hugo is lightning fast compared to other SSGs. My biggest Hugo site has… <goes off to count> …338 posts, mostly image heavy, plus a few static pages –and it still rebuilds in 3 or 4 seconds.

1 Like