Page Template External

Hi fellows

Just wondering if there is any documentation regarding external page?

When accessing the page (e.g. https://mysite.com/facebook), all I have is a RuntimeException (400) error:

image

I assume it will redirect to the external URL?

@blacklab, The menu of a Grav site is normally build-up using the page hierarchy of visible pages. An ‘External’ page can be used to create an extra menu item that links to an external page.

When, instead of using the menu item, the browser is pointed to https://mysite.com/facebook, the request is send to Grav, which tries to fulfill the request and needs to parse the page using template ‘external.html.twig’, which, as we know, does not exist and hence the runtime exception is thrown.

Although you are not using the functionality as intended, accessing the page url should not throw an error IMHO…

I’ve created an issue on Github for this.

How to redirect https://mysite.com/facebook?

If you don’t want to create the menu item but do want https://mysite.com/facebook to redirect to facebook, you have two options:

  1. Create a regular but invisible page ‘/user/pages/facebook/default.md’ and add the following to the header of the page: redirect: https://facebook.com
  2. Or add a redirect to ‘/user/config/site.yaml’. See Site Level Routes and Redirects:
    redirects:
      '/facebook': 'https://facebook.com'
    

Thanks @pamtbaau

Yeah, I was trying to let the client to set a link for a button, using custom page blueprint:

header.button.link:
  label: Link
  type: pages

Then if needed, the client can set the button to link to an external page as well as a page within Grav. Then with something like this in the twig:

<a class="btn" href="{{ page.find(header.button.link).url }}">
  {{ header.button.label }}
</a>

It all went well even with external page set to invisible. I was curious if it has the same effect as page redirect using a direct link to that page since the documentation doesn’t really mention it :sweat_smile: