Advanced Topics

Although the goal of PageFactory is to help non-technical users, you can extend it's functionality if you're willing to write a little code.

Pages with unique links and images are a common requirement for programmatic content. This can be done in PageFactory by adding a little HTML to your spreadsheet.


Any URL in your spreadsheet that should appear as a link in your content needs to be wrapped in an HTML anchor tag.


<a href= >Click here!</a>

Where the example says "", simply replace with your url. Where it says "Click here!", replace with the text you want the link to have in your content.

The html should be wrapped around the urls in your spreadsheet, like so:

demonstration of what links will look like in spreadsheet

In your PageFactory template, simply insert the variable where you'd like the link to appear.



Images work in a similar manner to links, only you'll use an HTML image tag instead.


<img src= />

Where the example says "", replace with a url to your image.

In your spreadsheet, it would look like this:

demonstration of html for images in spreadsheet

In PageFactory, insert the variable for this column wherever you would like your image to appear in the template. When it all comes together, the data in our example spreadsheet might look something like this:

example of what links and images template could look like

Conditional Statements

For the most part, PageFactory uses Jinja syntax to process templates. Jinja is a template engine for the Python programming language. You can write Jinja code in PageFactory templates and build some pretty complex content in the process.

Probably the most useful functionality you'll get from using Jinja is conditional statements. Say you only want to display certain information when a row in the spreadsheet contains a specific value. Conditionals are the answer.

Consider this example:


Here, we check if the value in the spreadsheet column "conservation" is equal to "high". If it is, we display the text in between {% if conservation == "high" %} and {% endif %}. We also use the double bracket syntax {{ name }} to output the value in the "name" column in the spreadsheet.

So, for the California Condor, the output text would be:

Currently, conservation efforts for the California Condor is considered a high priority. We must protect the California Condor!

But for the Golden Eagle it would read:

Currently, conservation efforts for the Golden Eagle is considered a low priority.

Overall, conditionals are pretty simple, and basically tell the template "if this, do that." They're a great resource for avoiding duplicate or thin content with programmatic SEO, and they can even be nested.

If you feel comfortable with conditional statements, and want to try more advanced tactics, check out Jinja's full documentation. It provides guidance on implementing more complex functionality such as for loops and filters.