Skip to main content

Can I migrate to Kuroco without changing existing article URLs?

When migrating to Kuroco, it is possible to keep existing article URLs (e.g., https://example.com/blog/12345/) unchanged, although some configuration is required.

For example, you can take the following approach:

  • Migrate existing articles with a slug like blog-12345
  • Create a trigger to auto-generate slugs in the format blog-[topics_id] for new articles added in Kuroco
  • On the frontend, for a page like /blog/12345/, fetch the article using the slug blog-12345

Step 1: Migrate existing articles with slugs

When importing existing articles, set the slug for each article to match the current URL path.
For example, if the existing URL is https://example.com/blog/12345/, set the slug to blog-12345.

tip

Slugs can be set via the "ID/Slug" field in the content editor, or included as a column when uploading content via CSV.

Step 2: Skip content IDs to avoid conflicts

Since existing articles use their old IDs as part of the slug (e.g., blog-12345), you need to ensure that new content IDs assigned by Kuroco do not overlap with the migrated article numbers.

Go to Environment settings -> Admin panel and use the "Next content ID" setting to skip the content ID numbering to a number that won't conflict with migrated articles.

For example, if the highest migrated article number is 12345, set the next content ID to 12346 or higher.

Step 3: Create a trigger to auto-generate slugs for new articles

Create a custom function with the trigger "After adding content", targeting the relevant content definition ID, to automatically set the slug when new content is added.

Trigger sample code

{* Trigger: After adding content *}
{* Auto-generate slug in the format "blog-[topics_id]" *}

{* Skip if in a loop *}
{if $smarty.server.HTTP_RCMS_X_API_REQUEST_CNT > 0}
{return}
{/if}

{* Build the slug using topics_id *}
{assign var='new_slug' value="blog-`$topics_id`"}

{* Update the content's slug via api_internal *}
{assign_array var='body' values=''}
{assign var='body.slug' value=$new_slug}

{api_internal
var='response'
status_var='status'
endpoint="/rcms-api/1/topics/`$topics_id`"
method='POST'
queries=$body
member_id=$smarty.session.member_id}
tip

If the original URLs used zero-padded IDs, you can use the string_format modifier to format the digits (e.g. {$topics_id|string_format:"%06d"}). See Modifiers for details.

info
  • $topics_id is a variable available in the "After adding content" trigger, and is assigned the ID of the newly created content.
  • The api_internal plugin sends an internal API request to update the content. You need to have an endpoint configured for updating content (e.g., Topics::update). For details, see Can I call Kuroco's API using custom function?

Step 4: Fetch content by slug on the frontend

On the frontend, extract the ID from the URL and pass the slug directly as a path parameter to the Topics::details endpoint.

Fetch example (JavaScript)

// Example: Fetching content by slug on a page like /blog/12345/
const id = '12345'; // Extract from the URL path

const response = await fetch(
`https://your-site-key.g.kuroco.app/rcms-api/1/topics_details/blog-${id}`,
{ method: 'GET' }
);

const data = await response.json();
console.log(data.details.subject); // Article title

Support

If you have any other questions, please contact us or check out Our Slack Community.