Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Count of Pages in a Space

Christopher Taverna July 27, 2017

I would like to get a count of the number of pages in a space and place it on a page. I'm guessing writing a macro will accomplish this but I am not sure how to write it. I've looked over all of the documentation, but it hasn't really helped. 

On the page itself it would look like: "There are {PageCountMacro} pages in this Space." and rendered it might look like: "There are 8 pages in this Space." if there were 8 pages in that particular space...  

3 answers

2 votes
Josh Kennedy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 29, 2024

A silly but functional workaround to find how many pages are in a Confluence space:

1. Click "Space Settings"

2. Click "Export space"

3. Click "PDF"

4. Click "Next"

5. Click "Custom Export"

6. Click and hold down the mouse button before the title of the first page at the top of the list

7. While holding down mouse button, hit "End" key

8. While holding down mouse button, drag cursor to the end of the last page title in the list

9. Ctrl/Cmd+C to copy the text

10. Open Microsoft Word

11. Paste text into Microsoft Word

12. Remove any incidental line breaks at the top or bottom of the list

13. Use the "Word Count" function, this will count the number of lines, since every page is on its own line, this will give you a total page count for your Confluence space

Angela L_
Contributor
August 23, 2024

This worked for me, but I found a few ways to make it simpler. After you copy the list of pages (step 9 above):

  1. Paste it into Notepad or some other similar program to strip out all of the formatting.
  2. Then copy and paste it into Excel.
  3. Scroll to the bottom of the spreadsheet, and ta-da! The bottom row is your page count. 
Dragos Suciu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 7, 2024

Hi there,

A quick note to this workaround. I've just discovered that pages with edit/view restrictions (or inherited restrictions from parent pages) will not be displayed on this list.

If you want to be sure you have all pages displayed, go to 'Space Tools' > 'Content Tools' > 'Reorder Pages' and expand all collapsed pages in the tree. Then you can copy this list and follow the tip above.

Alternatively, if you have access to the database, it's easiest to just run this query:

SELECT c.CONTENTID, c.TITLE
FROM SPACES s
JOIN CONTENT c ON s.SPACEID = c.SPACEID
WHERE s.SPACEKEY = '<space_key>'
AND c.CONTENTTYPE = 'PAGE';

Hope this helps! 

0 votes
Johan Theunissen
Contributor
March 21, 2025

Why isn't this a simple metric on a space!

0 votes
AnnWorley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 27, 2017

Hi Christopher,

I found a similar question in the Community which had lots of answers: How many pages in a space? Some user macros were recommended, including Count pages in space. So you may not have to write your own macro. :)

Thanks,

Ann

Christopher Taverna July 28, 2017

Thank you Ann! I've tried $spaceManager.findPageTotal($space) which does return a number. However, it appears to be returning a number that is double the number of pages. Any suggestions?

Update - I tried on a few other spaces, and it is not always double the number, but it is always more... I don't have any pages in the trash, so that shouldn't be an issue.... Thank you!

Like # people like this
Max Haley
Contributor
September 18, 2022

Hello,

I have just found that if you create an 'index' using the '/index' option, it will give you the number of pages start start with each letter of the alphabet. You can then just knock the total up in calculator

Hope it helps.

Like Yuri Makaruk likes this
Yuri Makaruk
Contributor
October 23, 2023

Always amazed by the ability of Confluence to make simple operations difficult to do))) 

Like # people like this
Max Haley
Contributor
August 30, 2024

🤣

Robert Reiner _smartics_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 2, 2024

Just regarding the number of pages returned by $spaceManager.findPageTotal($space). The API documentation says this:

Get the number of pages in a space. This counts all pages, including non-current versions, and including pages that are in the trash. As such, it probably doesn't do what you think it does.

Maybe the PageManager has an operation that meets your needs? I only consulted the API docs and I am not sure if 'current' does indeed not include pages or blog posts you do not want to count.

/**
* Get total number of current pages in a space
*
* @param spaceKey the space to look for posts in
*
* @return a count number of pages
*
* @since 6.1.3
*/
long getPageCount(@NonNull String spaceKey);
Like mbougard_sigma_fr likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events