I just want to know how many pages are in a Confluence space without having to manually count or run a SQL query. I know the usage tracker plugin used to do it, and it was disabled by default because it impacted performance, but I cant find it even to run for a bit and then re-disable. Any other ideas>? I dont need anything fancy, just a page count.
Thanks,
Emily
If you have the Reporting plugin, you could use this markup:
{report-info:space > all pages > size}
OR you could create a user macro.....
Name: pagecount
No Macro Body
Output generates wiki markup (or HTML doesn't really matter)
Template:
## get page manager...
#set($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
#set($pageManager=$containerContext.getComponent('pageManager'))
#set($pageCount=$pageManager.getPages($space,true).size())
Page Count: *$pageCount*
The fix described by Matthew above works for me, but only in the current space. If I do {pagecount} I get the number of pages in the current space.
Is there any syntax that would allow me to count the pages in a different space?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jim,
I added another line to the user macro Count Pages in a Space. Check the green tip box.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeremy, thanks but that doesn't seem to work for me. I should probabaly have mentioned that I'm on version 3.1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jim, Jeremy's version is a much cleaner solution but it only works for 3.5+. I'm still working with 3.2 in our production instance and the updated example below should (hopefully) work for you (although I haven't got 3.1 to test it on)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Matthew, there are plans to upgrade from 3.1 straight to 3.5. I'm hoping a lot of our problems go away then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I used the pagecount macro, which you kind of create yourself. (I'm on version 3.5) Worked a treat. Thanks, Matthew!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SQL-- Show number of CURRENT PAGES (as opposed to historical versions of pages) in every space:
SELECT spacename, COUNT(*) FROM spaces s JOIN content c ON s.spaceid = c.spaceid WHERE c.contenttype='PAGE' AND prevver IS NULL GROUP BY spacename ORDER BY spacename;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks this helped
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One brute force method that I have used is to:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For Confluence Cloud users, consider using REST API because Confluence Cloud doen't support SQL, Macro, or some Add-ons for stats.
A_USER="admin" A_PASSWD="__YOUR_PASSWORD_HERE__" INSTANCE_HOST="__YOUR_SUBDOMAIN_HERE__.atlassian.net" # Total number of pages curl -sGLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/search" --data-urlencode 'cql=type IN (blogpost, page)' --data-urlencode 'limit=0' | jq '.totalSize'
Refer my related answer at For Confluence Cloud, how do I find the total number of pages? for more detail if you needed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works well for all pages, provided you heed my note I added to your link about use of passwords being deprecated.
I'm interested in how to restrict this search to a single space. I tried adding --data-urlencode 'cqlcontext={"spaceKey":"KEY"}' but it seems to make no difference.
But adding "and space = KEY" to the cql seems to do the trick. Eg:
A_USER="admin" A_TOKEN="__YOUR_TOKEN_HERE__" INSTANCE_HOST="__YOUR_SUBDOMAIN_HERE__.atlassian.net"
SPACE_KEY="__YOUR_KEY_HERE__" # Total number of pages curl -sGLu ${A_USER}:${A_TOKEN} "https://${INSTANCE_HOST}/wiki/rest/api/search" --data-urlencode "cql=type IN (blogpost, page) and space = $SPACE_KEY" --data-urlencode 'limit=0' | jq '.totalSize'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Modification of original user macro which takes the Space Code as the body of the macro
e.g. {pagecount}CONFTEST{pagecount}
## get page manager...
#set($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
#set($pageManager=$containerContext.getComponent('pageManager'))
#set($spaceManager=$containerContext.getComponent('spaceManager'))
#set($targetSpace=$spaceManager.getSpace($body))
#set($pageCount=$pageManager.getPages($targetSpace,true).size())
#set($spaceName=$targetSpace.getName())
Space Name: *$spaceName*
Page Count: *$pageCount*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can this be modified to get a count of child pages of a certain parent page?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In Confluence, do an Advanced Search with the space selected and content = pages. Leave the search field blank. There will be a search result for every page. At the top of the search results page it will tell you how many results there are. Number of results = number of pages.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I reopened this question. Questions need not be closed just because they're answered :).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I figured I could write a quick user macro for this, so I went to go look at the available community User Macros, and there's one already. See Count Pages in a Space.
And, yes, I was indeed to my surprise to see that I was the author! Can't remember that at all... So, let me know if that doesn't work on your version and needs an update.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeremy, I don't think that one works any more, not since they lost the .getPages() from the space object (3.1 cleanup?)
my attempt gets hold of the pageManager object to call it's getPages() method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're right, sorry about that! I figured out what needs to happen in 3.5 and posted again. You need to use spaceManager:
$spaceManager.findPageTotal($space)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
findPageTotal returns a basically useless number that includes all versions of the pages. The JavaDoc notes "this probably doesn't give the number you are looking for."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any replacement for this in Confluence 5.5? as findPageTotel still appears to reutrn that number which isn't fit for this purpose.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a user macro that does it, accepting a single parameter representing the SpaceKey of the space on which to report:
## pagecount - no body, unprocessed, generates WM
#if ($paramspace)
#set ($space=${paramspace})
#else
#set ($space="WikiHelp")
#end
{report-table}
{space-reporter:space=$space}
{text-sort:space:name|mode=natural|order=ascending}
{space-reporter}
{report-column:title=Space}{report-info:space:name|link=true}{report-column}
{report-column:title=Pages}{report-info:space:all pages > collection:size}{report-column}
{report-table}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.