Using the new Directory page type without public profiles

In late October, NationBuilder quietly announced a new page type: directories. At a basic level, this page type allows you to create a directory of people in your nation. Sounds boring, right? Wrong.

As an Architect, I can tell you that this is one of the most commonly requested (previously) non-native pages in NationBuilder. The announcement of native support for it is a big leap forward. Now, people can easily created staff directories, listings of board members, etc. without custom coding at all. That’s a big deal for thousands of NationBuilder customers (including — possibly — you!).

But even beyond that, the new directory page empowers Architects and Experts to artfully pull very, very granular lists of people to display publicly on the website. Rather than displaying a random set of “supporters” from your database, you can now publicly display the photos of a targeted subset of your database. If you can tag people, you can display them on the site. That’s huge.

But there is a caveat to all this goodness: to use the directory page type at all, NationBuilder’s public profiles must be enabled. What does that mean, exactly? It means that “supporters” in your nation — all supporters, including all Twitter followers — will have a publicly viewable “profile” on your site. For a lot of folks this is a total non-starter, as it can lead to a lot of confusion (Why do I have a profile on your site?!), and can therefore turn them off from using the directory page.

But there’s another way. With a little custom theming, you can enable public profiles while tricking Google — and the public — into thinking they’re disabled. How? Let me explain.

To make this change:

  1. Navigate in your Control Panel to Website > Theme > Current Custom Theme > Templates > page_not_found.html. Copy all the code in that template, and return to the template list (the immediate prior page).

  2. Now, open the profiles_show.html template. Replace all of that template’s code with the code you copied in Step 1. Save and publish that template.

  3. Now, return to the templates list and open your layout.html template.

  4. Find the line that reads {{ page_title }}, and replace it with:

    {% if profile.published_name.size > 0 %}Page not found{% else %}{{ page_title }}{% endif %}
  5. On the next line below, paste the following code, which instructs Google and other search engines to ignore the page when indexing your website:

    {% if profile.published_name.size > 0 %}<meta name="robots" content="noindex">{% endif %}
  6. Save and publish your layout.html file.

Now, your site’s public profiles will appear to be missing or non-existent pages — both to visitors and search engines — and you can use Directory pages at will.

Share this post