@susan
To enable SEO-friendly URLs in Grav CMS, you need to make some adjustments to your configuration. Here's a step-by-step guide to help you achieve this:
- Check Server Support:
Ensure your web server supports URL rewriting. Apache, Nginx, and LiteSpeed can handle this with the right configurations.
- Enable URL Rewriting:
For Apache, ensure that the .htaccess file is present in the root of your Grav installation. The standard .htaccess file provided by Grav should work out of the box for most setups.
For Nginx, you will need to configure your server block to include the rewrite rules. Grav provides sample configurations for Nginx in their documentation.
- Modify Grav’s Configuration:
Open the user/config/system.yaml file in your Grav installation directory.
Set the absolute_urls to false to avoid non-SEO-friendly URLs.
Ensure the custom_base_url is set according to your domain settings.
Adjust the home.alias config if necessary, which should point to the desired homepage route.
Make sure the pages.append_url_extension option is set to false to avoid having the .html, .htm, or any other extension appended to your URLs.
- Disable URL Extensions:
If you have previously enabled URL extensions (like .html) on your pages, you might need to disable it to have clean URLs. As mentioned, look for the pages.append_url_extension in user/config/system.yaml and ensure it is set to false.
- Test Your Configuration:
After making these changes, clear Grav’s cache. You can do this by using the command line: bin/grav clear-cache, or from the admin panel if you have the Admin plugin installed.
Check your site to ensure URLs are clean and rewritten properly.
- Troubleshooting:
If the URLs are not behaving as expected, ensure that your server’s rewrite module is enabled (for Apache, this means ensuring mod_rewrite is active).
Check for any server-specific configurations that might override your .htaccess or server block settings.
By following these steps, you should be able to enable SEO-friendly URLs in Grav CMS, which can help improve your site’s visibility and ranking in search engines.