It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I embed the content of a text file attachment into a wiki page?

I have a process that automatically attaches a file to a wiki page, and now I want to embed that text file into the page contents itself. Is there an equivalent to the {include} macro for text file attachments?

6 answers

I see the following options:

  1. You can write your own plugin
  2. You can write your own user macro and use it to display iframe with the attached file contents (not sure if that will work - just an idea)
  3. You could change your process to create/update Confluence page instead of attaching file and use excerpt macro whenever you need to include it on a different page.


Thanks for the response, but it really wasn't very helpful. Yes, there are lots of thing that I could do myself, but I was looking for someone that has already solved this problem.

Well... you did not state you wanted a working solution. I just gave some tips on how can you do it (which could be helpfull if you're not too familiar with Confluence)... so now you'll just need to wait for another response or you can start working on it yourself :)

I too would like to see something list the "View File Macro" for text files (

For example:

{viewdoc:name=my document.doc}
{viewppt:name=my presentation.ppt}
{viewxls:name=my spreadsheet.xls}
{viewpdf:name=my document.pdf}

But I would like to be able to do this with a text file like this:


I have lots of text file scripts that I want to display in confluence pages, but I don't want to have to edit, copy, and paste every single script. I just want to upload them as attachments to one page and then reference them in other pages. Much easier to upload a text file script after I have changed it than having to edit every single page and do the edit, copy, paste steps.

--- @ James Hines

Would this work around work for you? I know it is a stretch, and I'm not sure if this would produce the results you would want to see, but could you put your content in one cell of an Excel Speadsheet and then use this macro to display the content?


Good luck...

James, rather than attaching to a page, why dont you put the contents itself directly into the page, using the Confluence CLI?

@Renjith, what is confluence CLI?

A similar question has been asked before, and an answer provided at the old forum ( The solution involves generating a path using some Velocity objects to reference a particular attachment. The browser takes care of accessing the content of the file and rendering it. All of this Functionality is wrapped up in a user macro, so you can re-use it on multiple pages.

Link is broken :(

atlassian forums is gone now

Thanks everyone for your suggestions. Charles solution was the closest to what I am wanting to do. I created a user macro as suggested in the forum thread, and the solution is working in Google Chrome. On IE and Firefox it is more problemmatic. Seems like they each handle the <embed> tag slightly differently.

If you're only going to be accessing text files then you don't need to restrict yourself to the <embed> tag. An alternative is to use jQuery (client side code) to retrieve the contents of the attachment and insert it into another element, such as a div.

Here's an example to help you:

You wouldn't need the button-click trigger, just make the ajax call within the (document).ready() block.

I would expect this to overcome any browser specific issues.

I'd be interested in your finished solution if you could post it back here, as would others I expect. :)



Hi,  its just about 2015 - does anyone know of a solution for this use case?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Confluence Server & Data Center 7.0 is here!

Hello Community 👋🏼 I’m Makisa, a product manager on Confluence Server and Data Center. Confluence Server & Data Center 7.0, our latest platform release, is now available and we wanted to shar...

157 views 0 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you