Whenever you create a post or page, WordPress by default will save the URL in the format “http://www.yoursite.com/?p=1”. The last character indicates the post id, which will be added in a running sequence for each post or page.
But this URL format with post id does not provide any clue to users and search engines about the content on your page.
What is Permalinks?
In order to provide more descriptive URL structure, WordPress offers a solution called “Permalinks”. Permalink is the short form of permanent link since each post should be identified with an URL, which is permanent in nature. There are three types of permalinks in WordPress:
The structure of a default permalink will be your URL + post id as shown below:
Where 123 is a post id. Default permalink structure is also known as “Ugly” structure since user does not understand what is 123 and where it is coming from.
- Pretty Permalinks:
The descriptive URL containing useful information instead of post id number is also called as “pretty permalinks” in WordPress. Pretty permalinks are created using “mod_rewrite” module of an Apache server. Example of pretty permalink is:
Pathinfo permalinks also known as “Almost Pretty” is same as pretty permalinks except the addition of “/index.php” in the URL. Example of PATHINFO URL is:
WordPress Pretty Permalinks Settings
Pretty permanent link structure for your site can be set by clicking on the “Change Permalinks” button shown next to the URL in the WordPress visual editor or by navigating to “Settings > Permalinks” options. Under “Common Settings” you will see many options to choose how you want your URLs to be saved in WordPress.
Each option will add some suffix to your site URL to create a post/page URL as below:
- Default – adds post id to site URL.
- Day and name – adds date of publishing in YYYY/MM/DD format and post name.
- Month and name – adds month in the format YYYY/MM and post name.
- Numeric – adds archives and post id.
- Post name – adds post name.
- Custom Structure – user defined.
All options other than “Default” option are considered as a “Custom Structure” by WordPress. For example if you select “Numeric” option WordPress will automatically fill “Custom Structure” field as “/archives/%post_id%”
Custom Structure Tags
Following tags are supported in the custom structure field:
|Tag||Description||Format||Tag Example||Example Structure|
|%year%||Year of post publishing||YYYY||2014||/%year%/%postname%/|
|%monthnum%||Month of post publishing||MM||10||/%year%/%monthnum%/%postname%/|
|%day%||Day of post publishing||DD||31||/%year%/%monthnum%/%day%/%postname%/|
|%hour%||Hour of post publishing||HH||16||/%year%/%monthnum%/%day%/%hour%/%postname%/|
|%minute%||Minute of post publishing||MM||45||/%year%/%monthnum%/%day%/%hour%/%minute%/%postname%/|
|%second%||Seconds of post publishing||SS||56||/%year%/%monthnum%/%day%/%hour%/%minute%/%second%/%postname%/|
|%post_id%||Unique id of the post||N||12||/%year%/%monthnum%/%post_id%/|
|%postname%||Name of the post as used in slug||post-name||this-is-my-post||/%year%/%monthnum%/%postname%/|
- There is no need to enter your site URL, you only need to enter tag parameters and site URL will be added automatically to each post URL.
- It is recommended to use custom structure suffixed with post id or post name to avoid interpretation issues. For example, using a custom structure like “%year%/%monthnum%/%day%/” for your post URLs will conflict with the archival URL for that day.
- If your assign multiple categories or sub-categories to a single post, then the first category or sub-category in the alphabetical order will be added in the URL.
- In order to activate PATHINFO start custom structure tag with index.php/.
Once permalink is activated you can see the URL structure when creating a post or page in visual editor as shown in the below picture. Just click on “Get Shortlink” button if you want to see the post id for any reason.
Optional Category and Tag Base Settings
All your category and tag URLs by default will be having the following format in WordPress:
You can modify these base words under “Settings > Permalinks > Optional”.
For example, if you enter “topics” as category base then the category URL format of your site will be changed as:
- In order to activate permalinks option, WordPress needs to have a write access to modify your .htaccess file.
- You will see a message like “If your .htaccess file were writable, we could do this automatically, but it isn’t…” in your permalinks settings page if there is a permission error.
- Provide write permission to .htaccess file using FTP or hosting control panel when activating permalinks and then change the permission back to 660 or 644 to avoid anyone modifying it mistakenly.