
Ask HN: Converting Wordpress themes to Go templates? - tmaly
Is there any free software that can help in converting wordpress themes to the Go html&#x2F;template format?
======
patio11
That would be _incredibly_ difficult for an arbitrary WordPress theme, as
they're allowed to do a heck of a lot more than just present content from the
database in straightforwardly generated HTML and CSS.

Presumably you have a blog template and want to make a small utility or
portion of your site match the template visually, right? That is
straightforward to do with a bit of elbow grease: create a minimal blog post
with a placeholder $TITLE for the title and $POST for the body content,
publish it, save the HTML, then grep for $TITLE and $POST and replace with the
appropriate magic for your templating language of choice. You're probably done
now, or done modulo changing some paths to point from your application's
directory to wherever WordPress locates the CS/JS files.

This general trick helps make individual pages of a WordPress template into
any sort of templating system very, very quickly. I've used variants to e.g.
make WordPress and Rails apps pretend to be siblings as opposed to mere
housemates. (Note that you should examine your theme's licensing; it's highly
likely that this is a consequential choice if you're working with a theme you
obtained commercially and then embed that template into an application which
is not WordPress.)

If you want to duplicate functionality of WordPress like e.g. interfacing with
the database, offering a backend, etc... be forewarned that you are embarking
upon an ambitious and involved project.

~~~
tmaly
Pat, thanks. I was just hoping maybe there was something out there. The theme
I am using is horrible in terms of performance. It serves up 1.8MB on desktop
and 1.8MB on mobile. There are a ton of optimizations I could make with media
queries and compression. For now, I have been just slicing it up into standard
html/template pieces.

