Creating content menus during installation

Sometimes, there is a tight line that separates content from configuration. It's really common to have pages that define a structure, but those pages are content. For example, if I want to create a blog, usually it has an "about" page, that is content, but it's also part of the structure of the page, that is usually considered configuration.

In Drupal, handling these between environments, can be quite troublesome. But there are solutions: you can create the empty nodes programmatically and add them to a menu:

<?php

/**
 * Implements hook_install().
 */
function profile_install() {
  // We force the menu rebuild, so the new menu entries will be processed.
  menu_rebuild();

  // First we create the content.
  $node = new StdClass();
  $node->type = "page";
  $node->title = "About";
  // This is the URL alias.
  $node->alias = "about";
  // The author of the node. If omitted, Anonymous (uid 0) will be used.
  $node->uid = 1;
  node_save($node);

  // Next, we create the menu entry:
  $item = array(
    // We can't use the alias.
    'link_path' => 'node/' . $node->nid,
    'link_title' => 'About',
    // The machine name of the manu.
    'menu_name' => 'main-menu',
    // Misterious attribute, not documented. Without this, doesn't seem to work.
    'customized' => 1,
  );
  menu_link_save($item);

  // We clear the cache of the menu, so the new menu entries are loaded.
  menu_cache_clear_all();
}

And there you go! You have the nodes required for the structure created. Now the content can be added in the correct environment, but the pages will be ready in every environment.