CMS publishing to staging and production

jpetry's Avatar

jpetry

03 Jun, 2016 05:19 PM

We have a CMS install that publishes to three destinations: a staging site, and a production site that's load-balanced between two servers (www1 and www2).

The three Destinations are setup without any URLs, however, when the pages are published to the staging destination, the paths (such as to CSS files) are published with the "www" URL, not the "staging" one

How do we go about setting this up where the modified paths point to the appropriate domain? We tried setting the URLs specifically in the Destinations, but that didn't seem to work.

  1. 1 Posted by jpetry on 07 Jun, 2016 09:08 PM

    jpetry's Avatar

    Bumping, but adding more information.

    We have two site instances: _common and the main site itself. The pages are under the main site, but are using templates from the _common instance.

    The templates in the _common instance have code like this:

    <link href="/_files/css/main.css" media="screen" rel="stylesheet" type="text/css"/>
    

    Upon publish of this page, regardless of which destination is used, it gets translated to the "www" URL:

    <link href="http://www.thesite.com/_files/css/main.css" media="screen" rel="stylesheet" type="text/css"/>
    
  2. Support Staff 2 Posted by Tim on 16 Jun, 2016 06:53 PM

    Tim's Avatar

    Hi,

    Thanks for providing that additional information. In your initial description of the behavior you're seeing, it sounds to me like you're running into the scenario described on this feature request. Can you look over that and add your votes/comments if that does indeed sound like what you're looking to do? I just sent you an invite, so let me know if you have any trouble accessing that forum.

    As for your comment here - when you're linking to something in another Site, the link will automatically be rewritten to use the Site's URL property. So, if I'm understanding this correctly, it sounds like your _common Site has the URL http://www.thesite.com set for it at the Site object level. Can you confirm whether or not that is the case?

    Thanks

  3. 3 Posted by jpetry on 16 Jun, 2016 07:44 PM

    jpetry's Avatar

    That feature request you referenced, although similar, doesn't seem to be exactly what I'm experiencing.

    So, to be clear, the page is under the site instance - Site P we'll call it. The page uses a template under the _common instance.

    I just confirmed, with your suggestion, that modifying the URL for the _common instance will cause publishes of the page to use that URL.

    However, the Site P page gets published to multiple destinations. We don't want the URLs to be replaced - but rather remain relative. If it stayed at /_files/css/main.css things would be fine, as that path resolves for both load-balanced instances of www and staging. However, since everything using that template gets the _common URL, which we set to "www", staging publishes for that page point to "www" instead. We don't want this.

    What can we do to have this URL replacement work in a multi-environment instance like ours, to where it keeps it to the relative path (/_files/css/main.css) or considers what destination it's being shipped out to?

  4. Support Staff 4 Posted by Tim on 17 Jun, 2016 02:17 PM

    Tim's Avatar

    Gotcha. Yea, unfortunately there isn't any great way to do this that I can think of at the moment.

    What can we do to have this URL replacement work in a multi-environment instance like ours, to where it keeps it to the relative path (/_files/css/main.css) or considers what destination it's being shipped out to?

    As far as keeping that path relative (or I assume root relative in this case?), you might be able to try something like this in your Template in place of the current <link> tag you have:

    [system-view:internal]<link href="/_files/css/main.css" media="screen" rel="stylesheet" type="text/css"/>[/system-view:internal]
    <!--#passthrough<link href="/_files/css/main.css" rel="stylesheet" type="text/css"/>#passthrough-->
    
    I haven't been able to test if something like this would work, but it might based on how I'm thinking this should be processed. Give it a shot and let me know if you have any luck.

    Thanks

  5. 5 Posted by jpetry on 17 Jun, 2016 03:01 PM

    jpetry's Avatar

    This seems to be doing what we would expect. I'll pass this approach onto the other developer here who was affected by this - and let him work with this too.

    Thank you so much!

  6. Support Staff 6 Posted by Tim on 17 Jun, 2016 03:08 PM

    Tim's Avatar

    Ah, nice! OK, one thing you'll need to be careful about here is to make sure that the files in the shared directory never move. The reason for this is that the root relative link we just created in your Template (using the #passthrough notation) is not managed within the system (meaning that if the files referenced ever move, that path isn't going to be automatically updated...thus breaking all of your CSS once you publish to your web server(s)).

    The internally managed link (the one you see within the [system-view:internal] tags) will be updated automatically by the system if that CSS file is ever moved. This means that Pages should always look correct in the system because the path should always be right.

    I'm bringing this up because it could be potentially misleading to end users in the system since their assets should always look correct in the application, but could potentially be broken upon publish. Let me know if that makes sense.

    Thanks!

  7. Tim closed this discussion on 17 Jun, 2016 05:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac