contao / core

Contao 3 → see contao/contao for Contao 4
GNU Lesser General Public License v3.0
490 stars 213 forks source link

Checkbox to mark page as index #8615

Open tpk109 opened 7 years ago

tpk109 commented 7 years ago

Hi, if there is a page structure like

+Deutsch -+Mainmenu (Forwading to Home) --+Home

and I want Home callable through domain.de and not something like domain.de/home.html it only seems possible with a trick like:

+Deutsch -+Index -+Mainmenu --+Home (Forwading to index)

How about a checkbox in the page "Make this the index"?

asaage commented 7 years ago

Just set the alias of Home to index and you are done.

tpk109 commented 7 years ago

You mean the Alias, right? If that is like index, you get an infinite circle, as the index calls Mainmenu, and Mainmenu calls Home again.

asaage commented 7 years ago

My mistake - I can confirm the redirect-circle for the demo (which is contao 4) and 3.5. Maybe index can only be a direct child of root-page? and has to be the first regular child? In fact i have used forwarding-pages to build menu-structure before but never with the index-page nested inside.

fritzmg commented 7 years ago

@asaage Technically you can set the alias to index on any page. However, consider the following: when accessing the front end with an URL like http://example.org/ Contao does not have any information about which page should actually be accessed. Therefore Contao simply generates the first page within the respective website root. (If the the alias of that page is not index, Contao will redirect to its canonical URL.).

Now in the described scenario, Contao would display Mainmenu - but this is a redirect to Home which in turn has the alias index and thus its canonical URL is http://example.org/ and thus you'll get an infinite redirect.

While it is possible to set the alias to index for any other page as well, it does not make sense, because Contao will never know that you want this page to be the start page, since its canonical URL (http://example.org/) has no information about which page should be called.

In my opinion such a feature request does indeed make sense, because sometimes the site structure is categorized in some manner and you might want to have the start page somewhere within your site structure.

Instead of having a checkbox, Contao could also simply always display the page that has the alias index, if available. If not, it falls back to the first page of the website root.

asaage commented 7 years ago

Thank you for clarification @fritzmg . So as for now the sole purpose of setting the index alias on a page seems to be to prevent duplicate content like http://example.org/ and http://example.org/home.html.

fritzmg commented 7 years ago

Well not exactly. Since Contao 3.5.18 Contao automatically redirects http://example.org/ to http://example.org/home.html.

asaage commented 7 years ago

Contao could also simply always display the page that has the alias index, if available. If not, it falls back to the first page of the website root.

That would at least be my favorite behaviour and could be a feature for contao 4.

https://github.com/contao/core/blob/master/system/modules/core/classes/Frontend.php#L348-L364 https://community.contao.org/de/showthread.php?65252-Problem-mit-Startseite-bei-interner-Weiterleitung https://docs.contao.org/books/manual/3.5/de/03-seiten-verwalten/seitentypen.html#startseite

tpk109 commented 7 years ago

If a solution with writing index into the alias would be used, then an directly readable instruction pointing to this would be nice. A basic feature like this should not need googling.