Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-04-09 19:08:47

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 281
Website

Is it possible to generate html pages

Question friends! Is it possible to use Textpattern on a localhost server, local machine setup, and generate html pages that can then be uploaded remotely? Making sure the remote site is only html/css/js, no php no database.

Might not be but wanted to check! Thank you.


…………………
I <3 txp
…………………

Offline

#2 2021-04-09 19:18:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,286
Website GitHub

Re: Is it possible to generate html pages

Depends how many pages you’re talking about. If it’s just a few, write your local site, navigate to each page in a browser and Save as you go :)

If you want to script it, sure. I would make a sitemap section and output every page you want to index – even just the URLs – using <txp:article_custom>. Then, armed with that file, chuck it at cURL: loop over the list of URLs via a ten-line PHP script, and dump the output of each URL into a separate file.html based on its section/article name so you essentially generate a file structure that mimicks your site structure:

site/section1/first-article.html
site/section1/second-article.html
site/section2/another-article.html

If you then upload those alongside your image and files directories, you should have a static site, as long as your navigation works. You might have to store the files without extension or use some htaccess wizardry to strip the extension off or something.

Alternatively, the etc_cache plugin might work. That has a static cache built in so you can just browse around the site (or again get your script to hit every page you’re interested in) and that’ll build you a cache of your site which you can grab and upload as-is. I don’t know how it’s stored, so that might not be possible, but if the plugin’s directory structure mirrors your site structure, then you’re good to go.

I’m sure someone else will have some more concrete ideas. These are just off-the-top-of-my-head things that may or may not have any substance.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2021-04-09 19:20:01

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 281
Website

Re: Is it possible to generate html pages

Very cool thanks Stef! Will think about those angles


…………………
I <3 txp
…………………

Offline

#4 2021-04-09 19:23:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,286
Website GitHub

Re: Is it possible to generate html pages

Hope it works out. Barring the obvious question of why you’d want to do this, the ideas above may or may not work as they’re totally untested.

You might have issues with links needing to be rewritten as you output each page, so they fit your static files. But I would think if you omit the file extension when you export each page so the file structure looks like clean URLs, and your web server is told to serve all files, except those in the images/files directories, as HTML, it might work.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2021-04-09 19:40:57

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 281
Website

Re: Is it possible to generate html pages

It’s basically, my husband has written a static website for deployment for a friend, and although he’s made use of innerhtml to help with nav/header elements, I think having something even local to his machine to manage those reusable areas that could generate a downloadable html file would be so handy.. it wouldn’t even need to manage the structure, I like the idea of a button after ‘publishing’ an article to download the html page


…………………
I <3 txp
…………………

Offline

#6 2021-04-09 19:44:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,286
Website GitHub

Re: Is it possible to generate html pages

hilaryaq wrote #329760:

I like the idea of a button after ‘publishing’ an article to download the html page

Yep, lo-tech and it’ll work cos the article knows its URL and can use it to save the file in the right place in the local filesystem. Or you could go even lower tech and CTRL-S… as long as you’re disciplined about where you save it :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2021-04-09 19:47:36

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 281
Website

Re: Is it possible to generate html pages

:)


…………………
I <3 txp
…………………

Offline

#8 2021-04-09 22:13:34

etc
Developer
Registered: 2010-11-11
Posts: 4,259
Website GitHub

Re: Is it possible to generate html pages

Bloke wrote #329759:

You might have issues with links needing to be rewritten as you output each page, so they fit your static files. But I would think if you omit the file extension when you export each page so the file structure looks like clean URLs, and your web server is told to serve all files, except those in the images/files directories, as HTML, it might work.

Another option could be <txp:permlink wraptag="<+>.html" /> article links. Or just <txp:permlink />.html :-)

Offline

#9 2021-04-09 22:22:27

etc
Developer
Registered: 2010-11-11
Posts: 4,259
Website GitHub

Re: Is it possible to generate html pages

Bloke wrote #329757:

Alternatively, the etc_cache plugin might work. That has a static cache built in so you can just browse around the site (or again get your script to hit every page you’re interested in) and that’ll build you a cache of your site which you can grab and upload as-is. I don’t know how it’s stored, so that might not be possible, but if the plugin’s directory structure mirrors your site structure, then you’re good to go.

Yes, static pages/directories reflect the site structure and are stored in a root cache directory with .html extension.

Offline

#10 2021-04-10 09:28:56

gaekwad
Multi-hyphenate
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,531
GitHub

Re: Is it possible to generate html pages

Bloke wrote #329757:

I’m sure someone else will have some more concrete ideas.

SiteSucker and some search & replace for filenames / text.

Offline

#11 2021-04-11 07:42:30

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,509
Website GitHub Twitter

Re: Is it possible to generate html pages

I’ve not tried the latest etc_cache (with flat html support) yet but can vouch for earlier versions where chunks of code (large or small) can be stored in the database without loads of extra queries. Great plugin.

With the current interest in static sites (and headless/decoupled CMS) I’m definitely going to keep my eye on the various Textpattern solutions to it.

Offline

Board footer

Powered by FluxBB