Setting up website structure (routing)

Site structure in Webasyst is represented by a set of rules for processing requests from site visitors. Depending on the URL of the requested site page, Webasyst forwards the request to one of the apps installed in your Webasyst. These rules are managed in the "Structure" section of your Site app.


Why would you need multiple rules in the site structure

Adding new rules is necessary in 2 cases:

  1. When you need to use different design on some pages.
  2. When you need to use an additional app on some website pages.
If you do not need to use different design or a new app on your site, then there is no need for you to add a new structure rule.

1. Adding pages with custom design

Suppose that you want to add some pages to your site which must have completely different design; e.g., landing pages. In this case you have to add a new site structure rule. In this example, you may want to add a rule with URL /landing/*. In the rule properties select the desired design theme for its pages and the app in which you will create those pages; e.g., Site.

2. Using an additional app

Suppose that you want to add a blog to your site. To do so, install the dedicated Blog app via the Installer. Since you have installed a new app and want to use it on your site, you have to add a rule for it in the site structure.


Adding a new rule to the site structure

Click on "New rule" to show a popup area, in which you will have to do the following:

  1. Select an app.
  2. Enter the URL of that app's website section. When adding a new rule, ensure that its URL does not repeat any of the existing rules.

Other parameters are app-specific and are not very important for explaining routing rules, you may complete them at your discretion.


Choosing an app for the new rule

In Webasyst, every website page is generated by one of the installed apps. For example, online storefront — by Shop-Script 6, photo gallery — by Photos, informational articles — by Site, and corporate blog — by Blog.

Webasyst can help you display web pages generated by different apps in a similar style so that they appear as parts of one big online resource to your visitors.

Thus, you have to decide which website section will be generated by which of the installed apps, and at which URL that specific website section will be available.

Suppose you have made your choice as shown below:

  • website section at yourdomain.com/shop/ will be your online storefront (Shop-Script 6)
  • website section at yourdomain.com/blog/ will be occupied by the blog
  • all other website pages including the home page will be generated by the Site app

Now follow your plan and add routing rules exactly as listed above:

Note that you always have to add the * (asterisk) character for the URLs of website sections, it means that the section includes not only one page with the specified URL, but also includes all other web pages whose URLs begin exactly as that of the website section.

Compare:

  • yourdomain.com/shop/: a website section containing of only 1 page available at URL yourdomain.com/shop/
  • yourdomain.com/shop/*: a website section containing of an unlimited number of pages whose URLs begin with yourdomain.com/shop/; e.g., yourdomain.com/shop/category/food/, yourdomain.com/shop/category/tv/, yourdomain.com/shop/category/toys/, etc.


Setting correct order for site structure rules

The sort order of routing rules does matter! it depends on the number of URL portions separated by slash.

The more URL portions a rule contains, the higher must it be placed in the site structure.

Correct example:
shop/new/* (most detailed rule containing most URL portions)
shop/* (less detailed rule with fewer URL portions)
* (least detailed rule, which must be located at the end of the list)
Wrong example:
*
shop/new/*
shop/*

In the latter example, the least detailed rule (*) will "overlap" more detailed ones whose website sections will thus become unavailable. To fix this, you need to move this general rule to the bottom of the list. To move routing rules, use the icon on the left of the routing rule list:


How main site menu depends on the site structure

The links in the main menu on your site are not always defined by the site structure. Strictly speaking, the main menu mainly depends on the design theme rather than site structure. Depending on the current theme, main menu may be formed differently; e.g.:

  • by names of site structure entries,
  • by names of {$wa->apps()} menu set up in "Settings" screen of Site app,
  • by names of main pages created in Site app,
  • by names of main pages created in one of other apps installed in your account,
  • as an arbitrary set of links hard-coded in the design theme source code.

Read more on changing website main menu.

0 comments

    Add comment

    To add a comment please sign up or login