logo
Documents |

Manage your pages

Table of Content

Understanding Page


A website can have one or more pages, for example, if you have a website with the domain abc.com, you have may several pages:

  1. abc.com aka HomePage: this is the page where your visitors see if they simply type abc.com into to browser's address bar.

  2. abc.com/contact aka ContactPage: this is the contact page with all the form information your visitors see when they navigate to the address(url) abc.com/contact

A page will have a unique url structure as you see in the example above. It's important to note that a Page can have more than one URLs, let's see how:

If you decide to open an eCommerce website with Nilead, you may have 10 products to sell, you may want a web page that can display the detailed information of every single product. This page is normally called the ProductDetail page.

You have only 1 single ProductDetail page, but each of these products should have a different address(url) for the visitors to view the content corresponding to the specific product. In this case, you will have 10 urls that may look like this:

  1. abc.com/product/product-1-name

  2. abc.com/product/product-2-name

  3. ... abc.com/product/product-10-name

NOTE Page is associated with `Layout` to instruct how the content of the page should be displayed.

Managing your Pages

To manage your pages, on your Nilead admin, click Visual Editor then click Page.

click-visual-editor-page_1628745731_big

Find the page you want to edit and click on its name.

Managing your Page Meta Tags

Meta tags are snippets of text that describe a page's content; the meta tags don't appear on the page itself, but only in the page's code. Search engines and other website crawlers may use these tags to extract useful information about your web page.

By default, Nilead does not expose all meta tags for your website(which can be overwhelming). To enable/disable the list of meta tags you can edit your website's meta settings.

To manage your meta tags list, on your Nilead admin, open the Quick Menu and search for Meta.

quick menu - metas - Nilead platform

seo meta config

Once you setup your global meta tags, you can go back to manage your individual pages. Inside the page's form, you will find the meta tag fields that you have turned on globally in the previous step. These fields will accept normal plain text as well as twig code.

page meta seo

If you use twig code, you will have access to all the base twig's macros, functions, and filters. You will also have access to the currentResource object which allow you to print out the name field of the current object for example. This will be documented in details in another article.

NOTE: This change may break your site if your twig code has syntax error, if you are unsure what to do please contact our support so we can do it for you FREE of charge.

Managing your Page URL

In theory, it's possible to change the url of any page on Nilead to anything you want. In practice, we recommend changing only:

  1. The urls of the static pages

  2. The root path part of the dynamic pages

NOTE This change may break your site, if you are unsure what to do please contact our support so we can do it for you FREE of charge.

Page custom code

You can add custom code and scripts that are applied to a specific page. This can be useful for adding additional HTML, CSS, JavaScript and more.

Adding Custom HTML & CSS:

  • <link>: The <link> tag defines a link between a document and an external resource.

  • <meta>: The <meta> tag provides metadata about your site and should always go in the <head> code section.

  • <style></style>: The <style> tag defines CSS styles in your page.

  • <script></script>: The <script> tag allows you to embed JavaScript in your page.


You can have different custom code:

  1. Header custom code: your custom code will be inserted before the closing </head> tag. Put your code here if it's meta tag code or anything that you want to load before the content of the page is rendered.

  2. Footer custom code: your custom code will be inserted before the closing </body> tag. Put your code here if something that can/should be delayed until the content of the page is rendered.

page - custom code - Nilead platform

NOTE You can use both normal `html` and `twig` code in the custom code sections.

You may be tempted to use the custom code to add Google Analytics, Meta Pixel, etc... Don't. We have built-in support for those common tools which can be set via plugin.

Global custom code

For global custom code, please refer to the corresponding Global Custom Code section in the Plugins' article.

Canonical URL

One of the common use of the custom code section is to add Canonical URL, we will not cover the concept of Canonical URL here but we will show an example of how it can be added:

<link rel="canonical" href="{{ nl_current_path() }}" />

NOTE: `nl_current_path` is a twig helper method to print out the Canonical URL. In most cases it is exactly what you need.


In some situation, however, you may want to customize your Canonical URL, in such case you can use Twig to do something like this:

{{ url(app.request.attributes.get('_route'),app.request.attributes.get('_route_params')) }}


One of the common situations is generation of Canonical URL for paginated listing page:

{#Lets find out the current page#}
{% set page = app.request.query.get('page', 1) %}

{% if page == 1 %}

{#If the page is 1, we want to exclude the page query string#}
{#Cannonical URL looks like this: https://domain.com/articles#}

<link rel="canonical" href="{{ nl_current_path() }}" />

{% else %}

{#If the page is not 1, we want to include the page query string#}
{#Cannonical URL looks like this: https://domain.com/articles?page=2#}

<link rel="canonical" href="{{ nl_current_path({'page': page}) }}" />

{% endif %}


You can paste the code above right into your Custom Code (header) like this:

page - custom code - header - Nilead platform

In the code above, you can see that we use Twig to:

  1. Find out the current page by accessing the query page.

  2. Check if page is 1 (default) then we print out the Canonical URL without page query.

  3. Check if page is NOT 1 then we print out the Canonical URL with page query.

Alternatively, you can also utilize the twig helper nl_canonical_url which is designed for this purpose:

<link rel="canonical" href="{{ nl_canonical_url({'page': 1}) }}" />


So with much less code, we simply have to tell nl_canonical_url the list of queries we need to include in the canonical url and the default value for each key.

Share

DIscord chat

We're available Monday–Friday, security and critical bug fixes are available 24/7.

Facebook page

Get the latest news and updates regarding Nilead platform and services.