Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Redirect in GRAV

Started by Aleksei 7 years ago · 6 replies · 2954 views
7 years ago

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
7 years ago

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 :)

7 years ago

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

👍 1
7 years ago

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|366x158

So I made this folder structure:

TXT
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"

YAML
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 :) 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):

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

But correct rule for redirect is this:

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

👍 1
last edited 09/24/19 by Aleksei
7 years ago

Hello,

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

7 years ago

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

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 80 9 hours ago
General · by pamtbaau, 15 hours ago
1 51 14 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago