Reordering Pages

Reorder Pages in the ReadMe Dashboard

There are two ways to reorder pages within your sidebar.

Option 1: Press and hold the page you want to reorder to drag, and then drop it, into its desired new location.

Option 2: Click the three dot menu next to any page and select the Move To option, and from there see the available categories where you can re-locate that page to.

You can also reorder pages to be subpages of another page by following these steps:

  1. Move the desired subpage below the parent page, move a second-level subpage under a different subpage, or move a second-level subpage to be a first-level subpage underneath a new parent page.
  2. Click and hold the page, drag it to below the desired parent page, and drop it below and slightly to the right. It will appear as a subpage. The process is the same whether you are create a first- or second-level subpage.

To undo this, simply move the subpage above the parent page and it will become a normal page.

How to Reorder Pages via API

How Ordering Works in Our API

To insert docs, you would use our Create Docs API

The way our docs ordering works is that each doc has an order attached to it and it works similar to how a z-index works in CSS. The numbers do not have to be consecutive, they are just sorted from low to high to determine the order.

By default, when a page is created it is set to 999. When multiple docs have an order of 999, we fall back to sorting by date created, so that newer pages always come last.

Our Update Docs API allows you to send us the order like so:

curl https://dash.readme.io/api/v1/docs/page-slug -X PUT \
 -u _api_token_here_: \
 --header 'x-readme-version: 1.0.0' \
 --header 'content-type: application/json' \
 --data '{"order": 1}'

So if you had a tree returned from a category that looked like this:

[
 {
  _id: 123,
  slug: 'getting-started',
 },
 {
  _id: 789,
  slug: 'another-page'
 }
]

To reorder these two pages so that some other page is first, you would issue two requests to the update page API (some headers omitted for brevity):

curl https://dash.readme.io/api/v1/docs/another-page -X PUT \
 --header 'content-type: application/json' \
 --data '{"order": 0}'
curl https://dash.readme.io/api/v1/docs/getting-started -X PUT \
 --header 'content-type: application/json' \
 --data '{"order": 1}'

The order is always returned from the API, so you will be able to determine what the current order is either from the tree (which will be correctly ordered), or from a single document.

Subpages

We have another property called parentDoc, which you assign to a document when you create/update it to determine what the parent is. So given the following tree:

[
 {
  _id: 123,
  slug: 'getting-started',
 },
 {
  _id: 789,
  slug: 'another-page'
 }
]

To create a nested doc underneath getting-started, you would issue the following request:

curl https://dash.readme.io/api/v1/docs -X POST \
 -u _api_token_here_ : \
 --header 'x-readme-version: 1.0.0' \
 --header 'content-type: application/json' \
 --data '{"parentDoc": 123, "category": "category-id" "title": "New nested doc" }'

This requires the parentDoc id, as well as the category id.