Issue
- If you are using a display page template to display the web content data on the page then it will generate the URL as like "https://localhost_or_domain:port/w/WCTitle".
-
In order to make SEO friendly URL, there might be a requirement to remove /w from the existing URL(https://localhost_or_domain:port/w/WCTitle).
Steps to reproduce:
- Go to Design--> Page Templates--> Display Page Templates and add a display page template: Provide a sample template name, and select the content type: Web Content Article. Subtype: Basic Web Content.
- Add a web content display widget, then publish the display page.
- Go to Content & Data --> Web Content --> and add basic web content "WC1". Make sure that the display page template is set as the display page from the right-side panel, then publish the content.
- Go to the created web content and click on view content from the 3 ellipsis dot option of the content. copy its friendly URL
- Observed behavior: http://localhost:8080/w/WC1
- Expected behavior[Modify the URL]: http://localhost:8080/XYZ/WC_sample_text
Environment
- Liferay DXP 7.4 U31
Resolution
- Modifying the URL including the "/w" is not possible with OOTB configurations because the "/w" is the constant value written in the Liferay source code which makes it as intended behavior of the portal.
-
As the "/w" is the constant value defined for the URL separator of the web content that is displayed via the display page template. This has been defined in the "FriendlyURLResolverConstants" class in the below code lines. To modify, you can override the code to meet your needs by customizing it accordingly.
Also, In the URL, after the constant value "/w" it's appended with $WC_Title. This may be modified from the UI configurations using the OOTB feature for the specific web content to ensure uniqueness. Please refer here for more information:https://learn.liferay.com/dxp/latest/en/site-building/displaying-content/using-display-page-templates/publishing-content-with-display-pages.htmlpackage com.liferay.portal.kernel.portlet.constants;
import com.liferay.portal.kernel.util.Portal;
public class FriendlyURLResolverConstants {
............
public static final String URL_SEPARATOR_JOURNAL_ARTICLE = "/w/";
.............
public static final String URL_SEPARATOR_Y_PORTAL_RESERVED =
URL_SEPARATOR_X_PORTAL_RESERVED.substring(1);
}
- Edit the existing web content, friendly URL section is available under the settings basic information which allows you to modify it.
-
A feature request addressing this case will be implemented and supported by Liferay in a future release: https://liferay.atlassian.net/browse/LPS-181894 (customization for "w" in the URL when the display page template is used). If you would like to inquire about the feature request, please post your questions here:
https://liferay.dev/ask/questions/feature-requests