Forum
Newbie Questions
I'm planning on digging my teeth into Perch over the weekend and I have a few questions to ask that will get me heading in the right direction. Looking through some of the documentation I couldn't find clear answers.
Remove/do not display the .php extension in the page slug/url.
When creating new pages can I have a different page name and page slug/url and possibly create a tag in the SEO template for the editor to enter the page slug/url?
Navigation, what is the best approach to setting up the Navigation so an editor can enter the nav label when they are creating a new page from a Master Page Template?
Thank you for any guidance!
Bob
hide-extensions
option for not outputting the extension in generated links:https://docs.grabaperch.com/docs/navigation/perch-pages-navigation/
Then you just need a rewrite rule to match the non-extension links to the real file names:
https://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/
I'm not quite sure what you mean here. You can name your pages whatever you like!
They can do that - it's the Navigation Text field.
Drew,
Thanks for getting back to me so quickly.
If I wasn't going to utilize the Perch navigation is there a way to hide the page extensions site wide? I use Nginx so I'm not using .htaccess but I can setup the re-write rules in my host.conf file.
I see the Navigation Text field, I was getting mixed up with navigation groups but I get it now.
Thanks again!
If you're generating your own navigation, then you can just remove the
.php
when you output the links. Nothing special needed in Perch.Nginx is no problem.
Thank you!
Drew,
To hide the .php extension in Nginx for SEF do you know what the proper rewrite code is? No matter what I do the .php extension is still shown in the url.
location / { try_files $uri $uri/ /index.php?page=$request_uri; }
Where is it coming from? The server rewrite rules will only affect the mapping of a non-exention URL to the actual page. It won't change the links in your page.
So what is the best way to not display the .php extension? In Modx I enable their Pretty URL's, is there a config setting in Perch?
Thanks
Bob
I'm not sure where these links are coming from? You said you are creating your own Navigation, so you would just link pages without the extension if you are writing your own link in the HTML. That has nothing to do with Perch, we don't rewrite HTML you enter.
If you are generating Navigation from within Perch then Drew explained how you stop Perch outputting the extension.
Rachel,
If I use the Perch Navigation then it works but when I use hard links like below no matter what I do the url has .php Ex: contact.php
<ul class="dropdown-menu"> <li><a href="contact">Full Width</a></li> <li><a href="about">About</a></li> <li><a href="services">Services</a></li>
Your server must be redirecting rather than rewriting the link then - it isn't anything to do with Perch.
Rachel,
I figured it out, not sure if this is the best solution but it works.
Thank you for your help.
location / { #try_files $uri $uri/ /index.php?page=$request_uri; try_files $uri.html $uri/ @extensionless-php; }