Use Node ID for Calendar Item and Blog Post URLs

Mike Bilz asked on September 14, 2017 19:39

Hello Kentico Team,

Potentially simple question.

I would like the Blog Posts and Calendar Items on my site to use their Node ID as their URL, rather than using the page title. Is this easy to do, and will it negatively effect all of the nodes I have already created?

Is it as simple as setting the "Page alias source field:" to Node ID?

Follow up question, what is the difference between the Node ID, Document ID, and Blog Post ID? Is there a better one to use for this situation?

Thank in advance.

-mike

Recent Answers


Trevor Fayas answered on September 14, 2017 20:41

Hi Mike,

To help you with this one, let's get a little background information.

Kentico's "Pages" have 3 main tables that build them.

  • CMS_Tree (NodeID) representss the actual 'node' on the content tree.
  • CMS_DOcument (DocumentID) represents that language variation of the node (ex, you can have an English and Spanish version of the same Node, so there would be 2 Document's with the same parent Node)
  • Related_Class_Table (???) Each Page Type has a table that stores the page-specific information, such as Blogs have a table "CONTENT_Blog" which contains the various fields. This is connected to the Document via the CMS_Document.DocumentForeignKeyValue

While the NodeID would uniquely identify a specific node on the tree, and if there is only 1 language (english) it is sufficient to get the correct Document from, it is NOT recommended that you use this in your references. The primary reason is that NodeIDs are just the incrementing RowID for the table. If ever you referenced something by NodeID, and that page is ever removed, you now have no way to point it to an new location or redirect it. Along with this, if you ever setup a Staging environment, the NodeIDs will change.

This is why the page path is determined by the NodeAliasPath, which acts as a sort of "Code Name" for the node.

You can set the Page Alias source field to NodeID and it can make the NodeAliasPath match the ID path if needed (upon creation only, existing one's wont be updated, you would have to edit the Properties -> Url to change that), however this may negatively impact your SEO as numbers mean nothing to search engines.

If you are looking for a more 'dynamic' approach, you can always modify your Blog listings to point to a /MyBlog/Blog/# page and point it to a special page that would capture the last portion of the url (through a special Url path in Kentico /MyBlog/Blog/{BlogNodeID}) and then use that value (via macro {% BlogNodeID %}) to render your content.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.