Live data from Hacker News

Static site generators need less rigid content APIs

fvsch.com

41–50 of 75 posts

Re: Static site generators need less rigid content APIs

#41
From the post:

> Originating in simple blog engines, static site generators treat pages as a single content chunk (often in Markdown) with some metadata sprinkled on top. If you need several long chunks of content (say, a product short description, long description, technical specs, and a list of vendors), you’re out of luck.

I've struggled with this too. I'd really like to write in unadorned Markdown, because I'm using Trello as a headless CMS[0], but I also want the Markdown to map to an object containing discrete chunks of content.

The solution I settled on is to map level 1 headings to separate properties. The content that follows each level 1 heading is converted to HTML and becomes the value of the corresponding property - unless the content is a code block, in which case the code block is parsed as YAML to get a nested object instead of HTML.

[0] https://github.com/dwilding/trello-kb

Re: Static site generators need less rigid content APIs

#42
post #12
post #3

Have you looked at gatsby? It doesn‘t fullfill all points but it comes closer than any other SSG. I think it fully satisfies 3, 4, 5 and 6. The content API that is not limited to filesystem data puts it in a different category than other SSGs for me. They also seem to have the ambition to take on wordpress. It can involve some configuration though. It doesn‘t make the use case in the article trivially easy either.

IMO, Gatsby is one of the biggest hammers for smallest nails. I mean, how many dependencies/ceremony do we need to convert .txt > .html? Webpack? Graphql? Client-side routing? I mean, if you want to have fun with shiny tech, go for it, but it really is the wrong tool for the job.

[deleted]

Re: Static site generators need less rigid content APIs

#43
post #36

Earlier quoted context omitted.

The bottom line is flexibility and speed. With Gatsby you get both. Only looking at it as a .txt > .html convertor is very limiting. I generate 1,500 webpages every day from custom datasources with Gatsby. Using React components gives me DRY code. This gives me very great flexibility during development and great SEO and speed in production.

> The bottom line is flexibility and speed Gatsby gives you neither. Give me a tree navigation. Oh, it's not supported? Now, in order to implement it, I have to figure nodes/graphql/webpack/fragments (I know the tech, but it it's _used_) to get a solution that I could whip up myself in 30 minutes if the tooling and techstach wasn't bogging me down. There is a hidden cost to large peices of software with high ceremony…

It most certainly gives flexibility. Speed could be read as page speed or development speed, and it certainly gives the former. The latter depends on your familiarity, I suppose.

Re: Static site generators need less rigid content APIs

#44
post #5

I do like the idea to have a statically generated site and have all the content in plain text managed via git. Unfortunately it is ideal for text oriented content only. Once there is a lot of images in your content it becomes a pain to manage it in a convenient way. I tried pelican, but failed as didn't find an acceptable way to write a content. I have a kind of blog with around 30 to 50 photos per post and there is…

If memory isn't playing tricks on me, you can go to staticgen and in the language pick bash. There was a sweet one developed with photos as front runner. It may or may not be what you are looking for.

Re: Static site generators need less rigid content APIs

#45
post #5

I do like the idea to have a statically generated site and have all the content in plain text managed via git. Unfortunately it is ideal for text oriented content only. Once there is a lot of images in your content it becomes a pain to manage it in a convenient way. I tried pelican, but failed as didn't find an acceptable way to write a content. I have a kind of blog with around 30 to 50 photos per post and there is…

Forestry.io is a CMS for static sites that includes a media management interface you might like[0].

We also support uploading images to Cloudinary instead of committing them to your git repo to prevent repo bloat.

Depending on what you're trying to do, a non-CMS option that will remove some of the tedium of inserting all these images is to take advantage of Hugo's Page Bundles feature[1]. With this you could just group a bunch of images in a folder and iterate over them in your templates.

[0] https://forestry.io/docs/editing/media-library/

[1] https://gohugo.io/content-management/page-bundles/

Re: Static site generators need less rigid content APIs

#48
I've been building websites since the mid 1990s (including everything from small personal sites to large content-managed sites for the BBC), and I now run an agency that builds WordPress sites for large non-profit clients. I've been looking at SSGs myself recently, and much as I like the idea of static sites I've come to very similar conclusions to the author. There are two observations I have about this from my perspective:

1. People often forget that "making your own" also entails a huge risk for a client. What happens if you go bust? We're constantly being contacted by organisations who were talked into a proprietary CMS and then left in the lurch when either their relationship with the agency broke down (which often happens in this situation because the agency know the client is locked into their CMS) or a company's lone developer left.

2. No content editor should have to use anything much beyond a Word-like interface, even if there are separate TinyMCE fields for separate areas in a page template. Even Markdown, which seems elegant and simple to developers, can cause all sorts of issues with non-technical content editors - and most clients outside the development bubble are non-technical. I feel like the lessons learned at the beginning of CMSes - for example, you shouldn't expect anything but pain from expecting clients to edit HTML - haven't been fully understood.

The one end-user benefit from SSGs seems to be that the site is packaged as static files and is therefore faster and easier to deploy, but is that really worth jumping through all these hoops? If any of these SSGs wants to reach a broader market, they'll need to have a WordPress-like interface that then publishes the static files and somehow manages to cope with dynamic things like search and filtering in an accessible way.

One service I've been interested by is https://www.hardypress.com/ (just tried it out, not affiliated in any way) which effectively takes a WordPress site and publishes a static version. They cope with form submissions in a similar way to Netlify (I think) and also deal relatively with querystrings that trigger a filtered listing. I think this is the only direction I'd be comfortable with for my clients because it gives them all the benefits of a user-focused CMS with a static site generator, while allowing them to take the site to one of the many other WP agencies if they choose to.

Re: Static site generators need less rigid content APIs

#49
I agree with the author that SSGs are tools written by developers for their own use. But what's great about the file-based, command-line-driven interface is that it's possible to hook the input side up to some more machinery if you want a GUI CMS.

I work for Forestry.io, and our product is a CMS that aims to ease the pain of non-developers managing content for static sites. We are committed to bridging the gap between copywriters and developers. I am a big believer in the potential for static sites to transform the web, but I realize there is a lot of ground left to cover.

Re: Static site generators need less rigid content APIs

#50
I'm part-way there with https://github.com/akavel/g-wiki (towards an "elegant", or maybe rather "stupid", static site generator):

• it is template-driven, via Go templates engine (the theme/wiki.tpl is the entry point, all other templates are loaded dynamically) — no need to put files in special place in hierarchy (unless you impose it on yourself);

• it has `glob` function for matching files by pattern, e.g. `glob "/20??-??-??-*.md"`, and can render the contents of files loaded this way;

• it has `matchre` function which allows simple editing of page contents (you should be able to cut contents before/after a ``, etc.); by the way, I kinda feel, that the three points above, taken together, probably already make it Turing-complete in some unholy, non-euclidean, blasphemous way, akin to C++ templates...

• the "only" caveat being... it's not actually a SSG (yet™). It's more of a "personal wiki/notetaking" app currently. But the next step and goal in its development is to convert it to a SSG, only I'm still pondering various approaches to go there. And... it's kinda on hiatus now, in that I'm not developing it recently. But if I will develop it, it'd be exactly to convert it to a SSG now, so you should be fairly safe to "watch" it on GitHub. If anything shows up in your inbox, most probably it'd be a set of commits converting it to a SSG. And this very thread on HN may, or may not, make me get back to work on that ;)

Please note it's also poorly documented as of now. Though it has some reasonable --help message contents, see: https://github.com/akavel/g-wiki/blob/fork/wiki.go#L49-L110

Also, for editing markdown, I personally like https://typora.io/ and, more recently, https://zettlr.com/

EDIT: You could actually already try running `wget` on it. This is actually one of the approaches I'm considering.

Post reply on HN