Redirect via toggle on one pager

Hi there,

I’m building my first project with kirby and want to implement a redirect to a maintenance page via toggle in the panel.
Here’s my code so far:

    if($site->toggle()->toBool() === true and $page->uid() != 'maintenance')
    else {

When using the snippet I get the error of too many redirects. The toggle itself seem to work fine and redirects to the desired page when set to ‘true’ but again throws out the error when switched back to ‘false’. What am I doing wrong?

Another question concerning redirects on a one pager ( I followed the recipe in the cookbook for the one pager setup which worked out great) is that in my case I have a blog section containing article teaser which on click lead to the article itself. What would be a proper approach to have all pages and its subpages redirected like mentioned in the cookbook via

<?php go() ?>

except the blog pages?
It’s more from a users perspective when managing content and opening the site from the panel.

Thanks in advance

The else part is unnecessary.

thank you, works! @moonwalk