Redirect in GRAV

Good day to all! I have a problem with redirect in GRAV. I have read documentation, but in the chapter “redirects” there are no information about in what file I should to write the rule for redirect. I tried to write redirect in the header of the page “default.md”, in the file ‘site.yaml’ and in the ‘system.yaml’, but it didn’t work:

redirects:
/tutorial/algebra/fractions: ‘/tutorial/algebra/fractions/theory’

I can visit the page “/tutorial/algebra/fractions” without redirecting to the page ‘/tutorial/algebra/fractions/theory’. Tell me please, where I made a mistake?

1 Like

Hi @Gray_and_Big, I have not used system.yaml or site.yaml for redirects but have used the page header redirect

Here is an example of a redirect from https://paulhibbitts.net/cmpt-363/193/ to https://paulhibbitts.net/cmpt-363/193/home:
https://gitea.hibbitts.openetc.ca/SFU/cmpt-363/raw/branch/master/pages/02.193/course.md

Hope the above helps,
Paul

The docs do say “you can override or add any of your own settings by editing the user/config/site.yaml file” under the heading “Site Level Routes and Redirects”. You must have missed that.

If it’s still not working, could you expand on what “it didn’t work” means exactly i.e. what is happening?

Good luck, cheers :slight_smile:

Thanks a lot, your advice was very useful for me :slight_smile:

1 Like

Thanks for your answer, I really missed some information above the chapter “Redirects”.
I tried to create page structure like this:

%D0%9E%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0

So I made this folder structure:

Tutorial
	01.algebra
		default.md
		01.fractions
			default.md
			01.theory
				default.md
			02.practice
				default.md
	02.geometry
	default.md

But I didn’t want to make separate page on site for the chapter “Fractions”. When user cliks on “Fractions” it has to redirect to the “Fractions\Theory”. So I wrote the rule for routing in the header of the file “Tutorial/01.algebra/01.fractions/default.md”

routes:
  default: '/tutorial/algebra/fractions/theory'

It worked, but another problem appeared. I suddenly found that the page “/tutorial/algebra/fractions/theory” opens on the link “/tutorial/algebra/fractions/theory/theory”, and the page “/tutorial/algebra/fractions/practice” opens by the link “/tutorial/algebra/fractions/theory/practice”. I was really surprised, because I wrote the rule for routions only for one page. After that happened I tried to found the rule for redirect :slight_smile: I wrote redirect in the file default.md in the folder “Fractions”, in the file site.yaml and system.yaml, but redirect didn’t work. Now I understand, that my mistake was that I wrote redirect like this (I copied this example from documentation):

redirects:
/jungle: '/blog/the-urban-jungle'

But correct rule for redirect is this:

redirect: '/tutorial/algebra/fractions/theory'

1 Like

Hello,

What if you don’t put a default.md file in your 01.fractions folder ?

I deleted the default.md file from folder ‘01.fractions’ and received 404-error when pressed ‘Fractions’ in the main menu of the site.

1 Like