This forum has moved, please join us on github discussions. We will keep these old posts available for reference. Thank you!

Apostrophe 2.13.0 released: better absolute URL generation

2.13.0: configuring an absolute “baseUrl” for your site to improve facebook og:meta tags, newsletter generation by tasks, etc. works better.

  • req.baseUrl is now also available as req.data.baseUrl, and thus available in templates. This is great if you need to link to your own assets at hardcoded relative paths. However see also baseUrlWithPrefix below.
  • req.baseUrlWithPrefix and req.data.baseUrlWithPrefix have been added. If your site uses or might use a prefix and your assets with hardcoded paths are served by Apostrophe, these are more suitable.
  • req.absoluteUrl is also available as req.data.absoluteUrl and thus in page templates.
  • The apostrophe-express module correctly reads baseUrl from the global options of Apostrophe, not its own options; it is accepted from its own options for bc but for the full benefit you should set it globally. A warning is displayed if you set it the other way.
  • The req objects returned by apos.tasks.getReq() now include these properties, and you can pass { url: '/some-relative-url' } if you want the absoluteUrl property to be based on a particular URL within the site. This is also used for unit testing.
  • Unit tests no longer pass the meaningless hostName global option.
  • Unit tests added for the above.