Creating Custom Macros for Specific Use Cases in Confluence

Welcome to this tutorial on creating custom macros for specific use cases in Confluence. Confluence is a powerful collaboration tool that allows you to create and manage content for your team or organization. Custom macros provide additional functionality and can be tailored to meet your specific requirements.

Example: Displaying Current Date and Time

Let's start with a simple example. We'll create a custom macro that displays the current date and time when inserted into a Confluence page.

<ac:structured-macro ac:name="info">
  <ac:parameter ac:name="title">Current Date and Time</ac:parameter>
  <ac:rich-text-body>
    The current date and time are: {date:yyyy-MM-dd} {time:HH:mm}
  </ac:rich-text-body>
</ac:structured-macro>

Step-by-Step Guide

  1. Log in to your Confluence instance and navigate to the page where you want to create the custom macro.
  2. Edit the page and switch to the macro editor by clicking on the "+" icon in the toolbar and selecting "Other Macros."
  3. In the macro browser, search for "User Macro" and select it from the list of available macros.
  4. Provide a name for your macro and click "Create." This will open the macro editor.
  5. Within the macro editor, you can define the macro's parameters, body, and formatting. Use the editor toolbar to apply formatting or insert placeholders for dynamic content.
  6. Save the macro by clicking "Save" or "Insert" depending on your Confluence version.
  7. The custom macro is now created and can be used on any Confluence page by typing its name or selecting it from the macro browser.

Common Mistakes

  • Forgetting to save the macro after defining its parameters and body.
  • Using invalid or reserved characters in the macro name, which can cause issues.

Frequently Asked Questions

1. Can I use custom macros in Confluence Cloud?

Yes, you can create custom macros in Confluence Cloud. The process is similar to the one described in this tutorial.

2. Can I share custom macros with other Confluence users?

Yes, you can export custom macros as part of a Confluence template or share the macro's code with other users. They can then import the macro or add it manually to their Confluence pages.

3. Can I include dynamic content from external sources in my custom macros?

Yes, you can use macros such as the "HTML" macro to include dynamic content from external sources or connect to other systems using Confluence's REST API.

Summary

Creating custom macros in Confluence allows you to extend its functionality and tailor it to your specific needs. In this tutorial, we covered the basic steps to create a custom macro and provided an example of displaying the current date and time. Remember to save the macro after defining its parameters and body. Avoid using invalid characters in the macro name to prevent any issues. Custom macros can be used in Confluence Cloud, and you can share them with other users by exporting or sharing the macro's code. Additionally, you can include dynamic content from external sources using macros such as the "HTML" macro. Start exploring the possibilities of custom macros in Confluence and enhance your team's collaboration experience.