940cbdbde921b1b01bc102855d1b90fb

Adding Custom Paths to Your Publish

When publishing to static on Strattic, we reference paths for all resources related to URLs. Here's how to add custom paths.

When your site is published to static, we reference paths for all resources related to URLs. Here’s how to add custom paths. You typically think of these as slugs, for example:

  • / (the homepage)

  • /about-us

  • /contact

Note: if you’re site is set up to use a “trailing slash” / at the end of your slugs, please add those to the end of your path, e.g. /about-us/.

These are all paths, and can also include different assets that needed to style the page (CSS), add interactivity to the page (JS) or supply data information (JSON). Examples of these paths might be something like:

  • /wp-content/themes/my-theme/style.css

  • /wp-content/plugins/cool-plugin/rad-scripts.js

  • /wp-content/uploads/random-json-we-need.json

All of these paths are added to our publish system. While we try to intuitively include everything for your site to function, sometimes our clever publishing robots don’t find everything (beep boop πŸ€–). The reasons for this vary, but you may have scripts needed that are not:

  • referenced in a page or post

  • properly enqueued

  • located in a standard wp- folder

That’s ok, we have a way you can add custom paths so we don’t miss a thing while publishing!

You can add the following as a mu-plugin, a custom plugin, or as part of your custom theme or child theme:

<?php

/**
* Adding support for custom paths.
*/
add_filter(
'strattic_paths',
function ( $paths ) {
$paths[] = array(
'path' => '/our-company',
'priority' => 6,
'quick_publish' => true,
);

$paths[] = array(
'path' => '/wp-content/themes/my-theme/style.css',
'priority' => 6,
'quick_publish' => true,
);

return $paths;
}
);

The above adds two paths: /our-company and /wp-content/themes/my-theme/style.css to the publish, specifically to Quick and Full publishes.

You can use this as a starting template, and refactor however you like.

Just make sure you don’t overwrite the $paths variable, and make sure it’s returned, or nothing will get published πŸ˜‰ πŸ€“ .

StratticΒ is an end-to-end managed WordPress static publishing and hosting platform.
Try it free for 14 days, no credit card required.

Did this answer your question?