Repository navigation
URL constants and moving databases across stages - #37
Conversation
|
@ericrasch @germanny Do y'all remember what wordpress features & plugins were breaking due to relative urls? I'd like to test this comprehensively before I consider it fixed |
|
The BWP Google Sitemaps plugin - https://wordpress.org/plugins/bwp-google-xml-sitemaps/ - did not work with Evolution, and we believed that it was due to the site_url option having /wp there instead of the full URL. I can't remember exactly but I believe the urls out putted by the plugin were incorrect. I am a little concerned what kind of SEO issues we're going to have with relative. We rely on Yoast SEO plugin to create canonical links for us, for example. Aren't these going to turn up as relative links now? According to advice from Google and Yoast, we want these and all the links on our sites to be absolute links, not relative. Canonical links need to be absolute. And given the number of pages we have on some of our sites that are super super similar (ie, ./masters/, ./history/masters/, ./accounting/, ./accounting/careers/, ./careers/ - these types of very similar links and more existed at one time on sites like OEDb.org and certainly could return in the future), this is going to turn into a rabbit hole of relative urls that the content team isn't going to be able to manage easily nor are we going to be able to keep track of well. A Yoast article calls them "spider traps," and I'm a little worried that with the way we do business that could be a real issue. I feel like there were a couple other issues but I can't find documentation on them so can't say what they were. Personally, I don't think it's nearly as big of a problem to do a couple very simple SQL queries or use a plugin or Screaming Frog to to identify and update the DB as needed with non-local or -staging urls. It's something that should be part of the dev's job and it literally takes 5 minutes to do. Just my two cents. |
|
Wait, URLs have to be absolute? This reminds me of SEO debates we had @ WhiteFence nearly 10 years ago =/ It's not that the paths are relative, but they omit the That's why most application frameworks & the like generate URLs that are paths (e.g. Having a Genesis currently hacks the absolute URLs (via I always felt the best solution (which is yet to be discovered in WordPress) is one that ensures resource URIs use paths, unless they're external. But that's the thing, I'm trying to apply how applications are built to WordPress, which like trying to herd cats. My patience for WordPress being suitable for this sort of workflow is strained at this point, so I'm cool to just back away & let ride whatever works with the "architecture" we're stuck with... |
|
I'll test the sitemaps and yoast plugins, but I suspect the issue really was a relative url in the runtime constants rather than urls saved in the database. |
… instead of making them entirely relative
|
Looks like there are still issues (plugin related) with relative urls in the database. To address this, I'm replacing the stage subdomains via the regex filter...instead of converting them entirely to relative urls. For example, on We'll get this: |
* Added canonical ServerName for apache (as bare domain, eg "example.com") * Moved Evolution class into scaffolded project with a DOMAIN const, added `getHostname` method * Wp config now setting WP_HOME and WP_SITEURL via `Evolution::getHostname` * DB rake task is translating urls for production to bare domain "example.com", all others as "$STAGE.example.com"
|
I think this latest couple commits will be a good fix! Here's what I've done:
|
|
So will |
|
@germanny Yes, the urls that are saved in the database come from the By standardizing those, we can ensure that any production activity will end up saving |
|
Slick! I'm think about 301s. If the site is meant to have |
|
We have only a handful of sites that don't use Also was wondering about the staging sites and if we had multiple staging branches, how would those be affected? One branch might have a plugin installed that's not on the main staging branch. Will that break the site? |
|
I thought the bare domain (non-www) was preferred in most cases...but I can add a setting in the generator to set the canonical production domain way or the other. As for 301s, it shouldn't be redirecting the user at all (except when logging into the wp admin), but rather just serve as the requested hostname. That said, the on-page links will all be using the canonical stage-specific domain. I'd suppose that, for SEO purposes, a bare->www (or vice versa) redirect should exist in the root htaccess? |
|
Support for multiple staging branches is always going to be shaky, as all staging branches share the same database. I believe Wordpress handles this as gracefully as possible though, deactivating plugins that are registered in the db but don't exist on the filesystem |
…neration to preserve customizations outside the Evolution block
|
Okay, www vs non-www is configurable: Added a rewrite rule to enforce it either way, supports https too. In the process, added support for preserving htaccess customizations |
|
That's pretty legit! |
…k www setting; updated Evolution php class to check www setting
|
Yep! The only lingering issue here is:
I'm not sure how to resolve this without output buffering...which I really don't want to do... |
|
Hmmm... let me think on this one a bit... |
…al urls Pulled htaccess templating out of #37 Based on genesis/wordpress robots: https://github.com/genesis/wordpress/blob/1e4ef9a7d72c612aabe96d8aa8d9da8a35b49610/generator/app/templates/web/robots.txt
Conflicts: lib/yeoman/index.js lib/yeoman/templates/web/_htaccess
Conflicts: lib/ansible/roles/apache/templates/vhosts/002-branch
|
@ericclemmons Thinking about merging this, and opening a separate issue for the URL disparities on |
URL constants and moving databases across stages

Relative URL constants have strange side effects ranging from non-fatal warnings in the admin to breaking poorly written plugins. The trade off was to be able to up/down databases between stages without worrying about hardcoded domains in the db data.
As a workaround, I've set the URL constants as absolute urls in wp-config, using the
$_SERVER[HTTP_HOST]$_SERVER[SERVER_NAME]variable, and then added someperl regex filteringwp-cli string replacing of the dumped sqlbeforeafter importing on db down/up operations.Fixes #35 (I hope)