The site map is one of the most important MeshCMS components. Since MeshCMS is file based, there is no site map defined in a database, so MeshCMS must figure it out by parsing the file system. The site map is not a simple list of pages: it is a hierarchical structure which follows some strict rules.
The key of the site map is the concept of welcome file. This concept is well known by webmasters. When you access http://www.site.com/somedirectory/somepage.html
, the file somepage.html
located in the /somedir
directory is sent to your browser. But when you access http://www.site.com/somedirectory/
, you are requesting a directory, not a file. In such case, a file with a specific name is searched into that directory and, if it is available, that file is sent to your browser. Usually this file is called index.html
, but more than one can be specified, and the first match will be used. The default for MeshCMS is to search for index.html
, then index.htm
and finally index.jsp
(you can change this by editing the web.xml
configuration file according to the Servlet specification). The result of this convention is that accessing http://www.site.com/somedirectory/
and accessing http://www.site.com/somedirectory/index.html
will lead to the same page.
MeshCMS uses the welcome files heavily. When it encounters a directory while parsing the website tree, it checks whether that directory contains a welcome file or not. If there is no welcome file, that directory is ignored, along with all subdirectories. This means that all pages included in that directory will not be included in the site map, and that users will not find those pages in the navigation menu.
Pages included in ignored directories are still available by using a direct link or by typing the full address in the browser location bar.
Why is the site map made this way? There are two main reasons. The first one is that if a directory without welcome file were included in the navigation menu, clicking on it would show a listing of the directory contents, or an error page if that listing is not allowed. So this is a way to force the use of a welcome page. The second reason is that there are many cases where a page must not be available in the navigation menu. Suppose that you want to use the include module template to add some news in your web pages. You will create a directory that will contain an HTML file for each news, and then you will use that directory as module argument. If none of the HTML files has the name of a welcome file, those news will not be inserted in the navigation menu directly, but they will still available for the module as expected. This is just an example of a situation in which a welcome file should not be used.
When a directory contains a welcome file, it is inserted in the site map, and all other items available in that directory are included as children pages. Items can be files (HTML or server-side pages) or directories (which must have their own welcome file as explained above).
This method has an important drawback: a page that is not a welcome file cannot have children pages. For example, there is no way to add a child page to http://www.site.com/somedirectory/somepage.html
. This is usually not a problem, since you can always create a page at the same level (for example http://www.site.com/somedirectory/otherpage.html
), but if you think you will want to add children pages to a page, use a new directory for it. Keep in mind that http://www.site.com/somedirectory/somepage.html
and http://www.site.com/somedirectory/somepage/index.html
are indexed exactly in the same way. If you create new pages using the Page Manager tool, leave the "Create enclosing directory" box checked, so you will be able to add children pages to your new page in future.