Tutorial: Building a Directory

Overview

This tutorial demonstrates how to generate an interlinked directory structure for a state-wide electrician firm that offers several services to every County and City in Tennessee, USA, namely:

  • http://website.com/county
  • http://website.com/county/city
  • http://website.com/county/city/service

Prerequisites

We’ll be using a specific Theme and Plugins in this tutorial, but you’re free to use any Themes or Plugins as part of your site building process.

  • WordPress: Latest Version
  • Theme:
    • WordPress Twenty Nineteen
  • Plugins:

As the focus of this tutorial is to understand how to build a hierarchical directory, we strongly recommend reading the Building Service and Location Pages Tutorial first, which covers a lot of the ground concepts needed here.

Tutorial: Building Service and Location Pages

Planning

We’ll create two Keywords

  • service: listing the services that the electrician business offers,
  • location: listing the locations that the electrician business offers their services in.

Creating the Service Keyword

To create the service Keyword, navigate to Page Generator Pro > Keywords in the WordPress Administration menu:
Page Generator Pro: Keywords: Menu

Click the Add Keyword button below the Page Generator Pro title, which can be found towards the top of the screen:
Page Generator Pro: Import CSV

The Keywords form will then be displayed, where you can define the following options:
Page Generator Pro: Keyword Form

  • Keyword:
    • This is the unique template tag that you’ll use in the Content Group when defining and generating content.
    • For our services, set this value to service
  • Terms:
    • CCTV Installation
    • Alarm Installation
    • Emergency Callout
    • Rewiring
    • Fire Alarm Installation
    • Emergency Lighting Installation

Click the Save button.

A notification will be displayed confirming that the Keyword saved successfully.
Page Generator Pro: Keywords: Success Notification

Creating the Location Keyword

To create our location keyword, navigate to Page Generator Pro > Keywords in the WordPress Administration menu:
Page Generator Pro: Keywords: Menu

To add a new Location Keyword, click the Generate Locations button below the Page Generator Pro title, which can be found towards the top of the screen:
Page Generator Pro: Generate Locations: Button

The Generate Locations form will then be displayed, where you can define the following options:
Page Generator Pro: Tutorial: Building Directory: Keywords: Generate Locations

  • Keyword:
    • This is the unique template tag that you’ll use in the Content Group when defining and generating content.
    • For our locations, set this value to location
  • Output Type:
    • The Output Type defines the data that you want to include for each Location, stored as a Term in this Keyword.
    • We can select from any of City, County, ZIP Code and Region.
    • Click inside the Output Type field, and select City from the dropdown list.  This will then include the City for each Location, stored as a Term.
      Page Generator Pro: Tutorial: Generate Locations: Output Type: ZIP Code
    • Click inside the Output Type field a final time, and select County from the dropdown list.
  • Sort Terms By:
    • The first dropdown option allows us to choose the order that Terms are stored against this Keyword.  We’ll work through the ZIP Codes alphabetically, so select the ZIP Code option.
    • The second dropdown option allows us to choose whether to order the Terms alphabetically in ascending or descending order.  We’ll work through the ZIP Codes in ascending alphabetical order, so select the Ascending (A-Z) option.
      Page Generator Pro: Tutorial: Generate Locations: Sort Terms By
  • Country:
    • Select United States from the dropdown list
  • Method:
    • The area method allows us to fetch every location based on the restrictions that we define.  This is useful if our business operates within a specific geographic boundary, such as a City, County or Region.
    • The radius method allows us to fetch every location within the given radius of a starting point.  This is useful if our business operates on a call out basis within a specific distance of its premises.
    • For this tutorial, we’ll choose the Area option, assuming that our business operates within a geographical area.
  • Restrict by Region / Regions:
    • As we want to target all locations in Tennessee, which is a region (state) in the USA, we’ll start typing Tennessee into the Restrict by Region / Regions field.
    • After a few seconds, Tennessee will appear in the dropdown.
      Page Generator Pro: Tutorial: Building Directory: Keywords: Generate Locations: Restrict by Region
    • Click this option, so it is added to the field.  This means that locations will only be added to this Keyword that are within Tennessee, USA.
    • We could add further counties here if, for example, the business operates in multiple Regions.

With our form complete, click the Generate Keyword with Locations button.

The on screen progress modal will be displayed, whilst the Plugin populates the keyword with the list of locations.
Page Generator Pro: Tutorial: Generate Location Progress

A notification will be displayed confirming that the Location Keyword was generated and saved successfully.
Page Generator Pro: Tutorial: Generate Location Result

Creating Content

With our service and location keywords defined, we now need to build our content.

We’ll create three Content Groups:

  • County Content Group, to generate all top level County Pages
  • City Content Group, to generate all City Pages, which are children of the relevant County Pages
  • Service Content Group, to generate all Service Pages, which are children of every City Page

To create our Content Group, navigate to Page Generator Pro > Generate Content in the WordPress Administration menu:
Page Generator Pro: Generate Content: Menu

To add a new Content Group to Page Generator Pro, click the Add New button below the Content Groups title, which can be found towards the top of the screen:
Page Generator Pro: Generate Content:

You will then be presented with a screen similar to the one used to edit your WordPress Posts and Pages:
Page Generator Pro: Generate: Content

Creating Content: County Group

Title

Let’s start by defining the title that we want for each of our Pages.  We want our Page Title to be the County.

Start typing in the Title field, and a list of matching Keywords will be displayed.
Page Generator Pro: Tutorial: Building Directory: Generate Content: Title

Click the {location(county_name} keyword from the list of results.

Content

Define some content about the County.

This tutorial is not designed to be an exhaustive list of steps to producing truly unique content.  Refer to the Building Service and Location Pages Tutorial for further advice for this section.

Permalink

By default, WordPress will generate a Permalink based on the Title.  However, we can control the precise Permalink used by manually enter a Permalink now.

To do this, enter {location(county_name)} into the Permalink text field:
Page Generator Pro: Tutorial: Building Directory: Generate Content: Permalink

Generate

There are a few different ways that we can generate content, each of which are based on the keywords that we’re using:

Method Description
All The All method generates Pages for all possible unique combinations of the keywords specified in the Content Group.  This would ensure that every service and location combination has its own unique Page.
Sequential The Sequential method honors the precise order of each keyword’s terms.  This would mean that the first service and first location would be used for the first page, the second service and second location would be used for the second page, and so on.
Random The Random method generates Pages, choosing a term from each keyword at random for each Page that is generated.

We want to generate all unique Counties, so use the All method.

Overwrite

The Overwrite option allows us to overwrite existing Pages that were previously generated by this Group, matching the Permalink.  We’ll need to do this, because in our location keyword, the same County is listed for each City that’s listed.

Set this option to Yes
Page Generator Pro: Tutorial: Content Group: Overwrite

Actions

In the Actions box, click the Save button:
Page Generator Pro: Tutorial: Actions

The screen will update, confirming that the Content Group has been published (or updated, if we’re saving an existing Content Group):
Page Generator Pro: Tutorial: Save Confirmation

Generating Content

Click the Generate button in the Actions section of the screen:
Page Generator Pro: Tutorial: Actions

A new screen will appear, showing a progress bar and log.  As each page generates, the progress bar and log will update:
Page Generator Pro: Tutorial: Building Directory: Generate

We now have our County Pages, for example:

  • http://website.com/rutherford-county/
  • http://website.com/dickson-county/
  • http://website.com/shelby-county/

Creating Content: City Group

With our top level County Pages generated, we now need to generate the child City Pages.

Create a new Content Group, defining the following:

  • Title: {location(city_name)}
  • Content: Define some content about the City.
  • Permalink: {location(city_name)}
  • Method: All
  • Overwrite: Yes

Attributes

The Attributes section allows us to define the Page Parent to use for all Pages generated in the City Group.  In this example, we want our City Pages to be children of their respective County Pages.

To do this, define the Parent as {location(county_name)}
Page Generator Pro: Tutorial: Building Directory: Generate Content: Attributes

Actions

In the Actions box, click the Save button:
Page Generator Pro: Tutorial: Actions

The screen will update, confirming that the Content Group has been published (or updated, if we’re saving an existing Content Group):
Page Generator Pro: Tutorial: Save Confirmation

Generating Content

Click the Generate button in the Actions section of the screen:
Page Generator Pro: Tutorial: Actions

We now have our City Pages, for example:

  • http://website.com/rutherford-county/aberdeen-park/
  • http://website.com/dickson-county/abiff/
  • http://website.com/shelby-county/acklena/

Creating Content: Service Group

With our secondary level City Pages generated, we now need to generate the child Service Pages, which will form the third and final level of our directory structure.

Create a new Content Group, defining the following:

  • Title: {service}
  • Content: Define some content about the Service.  You could include information about the location, too.
  • Permalink: {service}
  • Method: All
  • Overwrite: Yes

Attributes

As explained earlier in this Tutorial, we use the Parent setting to define each generated Page’s parent.

As we want our Service Pages to belong to every city and county, we’ll define the Parent as:
{location(county_name)}/{location(city_name)}

Page Generator Pro: Tutorial: Building Directory: Generate Content: Attributes

Actions

In the Actions box, click the Save button:
Page Generator Pro: Tutorial: Actions

The screen will update, confirming that the Content Group has been published (or updated, if we’re saving an existing Content Group):
Page Generator Pro: Tutorial: Save Confirmation

Generating Content

Click the Generate button in the Actions section of the screen:
Page Generator Pro: Tutorial: Actions

We now have our Service Pages, assigned to every unique city and county combination. For example:

  • http://website.com/rutherford-county/aberdeen-park/cctv-installation
  • http://website.com/dickson-county/abiff/cctv-installation
  • http://website.com/shelby-county/acklena/cctv-installation
  • http://website.com/rutherford-county/aberdeen-park/alarm-installation
  • http://website.com/dickson-county/abiff/alarm-installation
  • http://website.com/shelby-county/acklena/alarm-installation

Interlinking Content

For both search engine optimization, and to help visitors easily navigate through your directory’s content, we can use the Related Links Shortcode on each of our Content Groups.

This will output a list of internal links to relevant content.

We’ll edit each of our three Content Groups, adding a Related Links shortcode to each.

We want to display links to all Cities generated from our City Group, that are specific to each County.

Edit the previously created County Group, and in the Visual Editor, click the Related Links shortcode icon:
Page Generator Pro: Generate: Shortcodes: TinyMCE Toolbar Button

Enter the following information:
Page Generator Pro: Tutorial: Building Directory: Related Links: County

  • Group: {location(city_name)}
    • This tells the Related Links shortcode to only display links to pages generated in the City Group (i.e. City Pages)
  • Output Type: List of Links
    • This tells the Related Links shortcode to display a list of links matching the given criteria
  • Number of Links: 0
    • This ensures that all generated City Pages matching the Group and Post Parent criteria are displayed
  • Post Parent: {location(county_name)}
    • This further tells the Related Links shortcode to only display links to pages generated in the City Group (due to the Group parameter above), where the Parent Attribute’s slug / permalink matches the County Page’s slug / permalink.
    • We need to do this to ensure that we only display City Pages where the City belongs to the County that we’re viewing – otherwise we would end up with all Cities displayed on every County Page, including Cities that belong to other Counties.

Click the Insert button, and the shortcode will be displayed in the content.

Click Save, and then Generate, to regenerate the existing Pages with our new content.

View a County Page, and you will now see a list of linked Cities belonging to that County, with each link going to a generated City Page:
Page Generator Pro: Tutorial: Directory: County Output

We want to display links:

  • To all Services offered in this City
  • To other Cities in the County that this City belongs to
  • To all Counties

Edit the previously created County Group, and in the Visual Editor, click the Related Links shortcode icon:
Page Generator Pro: Generate: Shortcodes: TinyMCE Toolbar Button

Services

Enter the following information:
Page Generator Pro: Tutorial: Building Directory: Related Links: Service

  • Group: {service}
    • This tells the Related Links shortcode to only display links to pages generated in the Service Group (i.e. Service Pages
  • Output Type: List of Links
    • This tells the Related Links shortcode to display a list of links matching the given criteria
  • Number of Links: 0
    • This ensures that all generated Service Pages matching the Group and Post Parent criteria are displayed
  • Post Parent: {location(county_name)}/{location(city_name)}
    • This further tells the Related Links shortcode to only display links to pages generated in the Service Group (due to the Group parameter above), where the Parent Attribute’s slug / permalink matches the format county/city.
    • For example, if our County is Davidson County, and the City is Antioch, we’ll only display links to Service Pages where:
      • County = Davidson County
      • City = Antioch

Click the Insert button, and the shortcode will be displayed in the content.

Other Cities

Enter the following information:
Page Generator Pro: Tutorial: Building Directory: Related Links: City

  • Group: {location(city_name)}
    • This tells the Related Links shortcode to only display links to pages generated in the City Group (i.e. City Pages)
  • Output Type: List of Links
    • This tells the Related Links shortcode to display a list of links matching the given criteria
  • Number of Links: 0
    • This ensures that all generated City Pages matching the Group and Post Parent criteria are displayed
  • Post Parent: {location(county_name)}
    • This further tells the Related Links shortcode to only display links to pages generated in the City Group (due to the Group parameter above), where the Parent Attribute’s slug / permalink matches the County Page’s slug / permalink.
    • We need to do this to ensure that we only display City Pages where the City belongs to the County that we’re viewing – otherwise we would end up with all Cities displayed on every County Page, including Cities that belong to other Counties.
The City Page that the visitor is viewing won’t duplicate and appear as a link in this section; the Related Links shortcode will never display an internal link to the same page that the visitor is viewing.

Click the Insert button, and the shortcode will be displayed in the content.

Counties

Enter the following information:
Page Generator Pro: Tutorial: Building Directory: Related Links: County Only

  • Group: {location(county_name)}
    • This tells the Related Links shortcode to only display links to pages generated in the County Group (i.e. County Pages)
  • Output Type: List of Links
    • This tells the Related Links shortcode to display a list of links matching the given criteria
  • Number of Links: 0
    • This ensures that all generated City Pages matching the Group and Post Parent criteria are displayed
We don’t need to set a Post Parent condition here, as we want to display all generated County Pages as links.

Click the Insert button, and the shortcode will be displayed in the content.

Generate

Click Save, and then Generate, to regenerate the existing Pages with our new content.

View a City Page, and you will now see link lists comprising of:

  • Services offered in the given City Page we’re viewing
  • Other Cities in the County that the City belongs to
  • County Pages

Page Generator Pro: Tutorial: Directory: City Output

For our Service Pages, we want the visitors to be able to:

  • View other Services offered in a given City
  • Navigate back up to the City Page
  • View the same Service offered in different Cities

View Other Services

Using the Parent, Next and Previous Links Output Type on the Related Links shortcode, we can display the next and previous Service links below the main content for each Service that we view.

Enter the following information:

  • Group: {service}
    • This tells the Related Links shortcode to only display links to pages generated in the Service Group (i.e. Service Pages)
  • Output Type: Parent, Next and Previous Links
    • This tells the Related Links shortcode that we want to display Previous and Next Links, to view other Services.
  • Parent Link: Title: Leave blank.  No Page Parent Link will display.
  • Next Link: Title: Set to %title.  %title will be replaced by the Next Page’s Title
  • Previous Link: Title: Set to %title.  %title will be replaced by the Previous Page’s Title
  • Post Parent: {location(county_name)}/{location(city_name)}
    • This further tells the Related Links shortcode to only display previous and next links to pages generated in the Service Group (due to the Group parameter above), where the Parent Attribute’s slug / permalink matches the format county/city.
    • For example, if our County is Davidson County, and the City is Antioch, we’ll only display links to Service Pages where:
      • County = Davidson County
      • City = Antioch
  • Order Links By: Title
    • This allows visitors to iterate through Services for a City alphabetically.

Click the Insert button, and the shortcode will be displayed in the content.

Navigate to City Page

Using the Parent, Next and Previous Links Output Type on the Related Links shortcode, we can display a link to the parent City page for each Service that we view.

Enter the following information:

  • Group: {service}
  • Output Type: Parent, Next and Previous Links
  • Parent Link: Title: Set to Back to %title%title will be replaced by the Next Page’s Title
  • Next Link: Title: Leave blank.  No next link will be displayed.
  • Previous Link: Title:Leave blank.  No next link will be displayed.
  • Post Parent: {location(county_name)}/{location(city_name)}
    • This further tells the Related Links shortcode to only display previous and next links to pages generated in the Service Group (due to the Group parameter above), where the Parent Attribute’s slug / permalink matches the format county/city.
    • For example, if our County is Davidson County, and the City is Antioch, we’ll only display links to Service Pages where:
      • County = Davidson County
      • City = Antioch

Click the Insert button, and the shortcode will be displayed in the content.

View the Same Service in Different Cities

Using the Link List Output Type on the Related Links shortcode, we can display a list of other generated Service Pages that have the same name as the service we’re viewing.  The Service Pages will be for different Cities.

Enter the following information:

  • Group: {service}
    • This tells the Related Links shortcode to only display links to pages generated in the Service Group (i.e. Service Pages)
  • Output Type: List of Links
    • This tells the Related Links shortcode to display a list of links matching the given criteria
  • Number of Links: 0
    • This ensures that all generated Service Pages matching the Group and Post Name criteria are displayed
  • Post Name: {service}
    • This limits the list of links to only display other generated Pages where the name (slug) matches the service we’re viewing

Click the Insert button, and the shortcode will be displayed in the content.

Generate

Click Save, and then Generate, to regenerate the existing Pages with our new content.

View a Service Page, and you will now see links comprising of:

  • Next / Previous Services Pages belonging to  the parent (City) Page
  • Back to City Page
  • This Service in other Cities

Conclusion

This tutorial has covered the basics of using Page Generator Pro to generate a hierarchical directory of locations and services, through:

  • Defining Keywords,
  • Creating Content Groups (template) for Counties, Cities and Services,
  • Understanding the Attributes > Parent option in Content Groups to correctly build a hierarchical directory structure.

There’s much more that Page Generator Pro can do, so be sure to check out the Documentation and any other Tutorials.