Textpattern : Pages and Sections
The two fundamental building blocks of Textpattern are pages and sections.
At its simplest, a Textpattern page is just the same as a static HTML page. It does, however, have the capacity to be much more than that.
Create a Static Website Using Textpattern
Textpattern works by using a database, and this is what gives it its power and versatility. But you aren’t compelled to take advantage of all the things a database can do. You can use Textpattern simply to display a static website if you want.
By learning how to convert a simple, static website into the Textpattern format, you will understand how the system’s building blocks work.
N.B. The screen-shot images in these tutorials were taken in 2024 and show the ‘Classic’ user interface of Textpattern version 4.8.8, the latest version at the time of writing. Things may look slightly different in future versions of Textpattern, although the essential features probably won’t change too much.
Static HTML to Textpattern
By converting a normal HTML page into a Textpattern page, and then creating a Textpattern section dedicated to that page, your original HTML page will become part of a database website.
This is how to do it:
- Click on Presentation, then Pages:
- If you are not presented with a blank Textpattern page, you will need to click the New page link. Create a new page by giving it a name:
- Take a static HTML page and paste it into the Page code box.
- Click Save. Textpattern will not remind you to save your work.
- Click the Sections tab:
- Click the New section box. You will see something like this:
- Fill in the Section name box.
- Look for the Uses page label. Next to it, click the drop-down box and select the name of the Textpattern page you have just created. For now, ignore all the other options.
- Click Save. Again, Textpattern will not remind you to save your work.
How Pages and Sections Link Together
A section is the primary structural unit of a Textpattern-based website. A section is the equivalent of a folder or directory in a static website. Each item in a Textpattern-based website’s main navigation menu will normally be a section.
The Textpattern page is a flexible template which can contain the HTML code, the text, the links, and anything else that appears on the publicly visible website.
The Textpattern section is what defines the Textpattern page’s relation to the other elements in the database.
An Entire Website Using Textpattern
You can convert a static HTML website into Textpattern very simply:
- Convert each static HTML page into a Textpattern page.
- Create a Textpattern section for each Textpattern page.
Linking the Pages
The only adjustment that’s needed is to change the links between the various pages from the standard HTML format to Textpattern’s database-friendly format.
So a link to a contact page would need to be changed from, say:go to our <a href="contact.html">contact page</a>
to this, if you are using messy URLs:go to our <a href="/?s=contact">contact page</a>
or this, if your web host allows you to use clean URLs:go to our <a href="/contact/">contact page</a>
Textpattern URLs
The section name will also appear by default in the URL, in the same way as a folder or directory will appear:https://www.mywebsite.com/contact/
Various types of URL are available. To select the type that suits you, go to Admin then Preferences then Publish, and use the drop-down box next to the Article URL pattern label:
Doing this will apply your choice of URL type to the entire site. Textpattern also allows you to use different URL types for different sections. You probably won’t want or need to do this, but if you do: click on the Sections tab, go to the appropriate section page and look for the Article URL pattern drop-down box, which is visible in the New section image above.
The main Textpattern site contains information about clean and messy URLs.
Advantages and Disadvantages
Of course, using Textpattern simply to create a static website may not seem worth the bother. You have one extra level of complexity over a standard HTML website: the sections that are needed to attach the Textpattern pages to the rest of the database.
Nevertheless, there are good reasons why you may want to do this:
- You get to use clean URLs, if your web host meets certain requirements, which almost all will do these days.
- You get to use a secure, spam-free contact form.
- Knowing how to create a static website with Textpattern is the first step in building a database website.
And a database website has many advantages over a static website. To create a database website using Textpattern, you need to know how to use Textpattern forms, which is what we will do next.
Next …
Continue with the next article: Textpattern Forms.
[This tutorial is part 2 of a series intended to introduce the Textpattern content management system to web designers who have no knowledge of PHP or databases.]