Replies: 7 comments 15 replies
-
That advice is new. Also Statamic doesn't ship with that right? So how could be a best practice I wonder 🤔. Does the Route without $site->url work with how Statamic ships by default (not with the absolute URL). If so I guess we'd better remove it. |
Beta Was this translation helpful? Give feedback.
-
Alrighty, did some testing and poking. Long story below with my findings, but in short: the absolute url's are just breaking the Social Images Generation functionality. Removing the {$site->url} will break the social-images url for any sites with a full domain.. ==== A clean install of Statamic/Peak, with Social Images Generation enabled, activates this route:
The default site config in config/statamic/sites .default is:
When converting to multisite through
When I return the '/' url for the default site, but add a full, absolute url for the second site (like 'my-dutch-site.nl' in case you would like to use a different domain for the second site, as per documentation), this would result in these two routes:
When I remove the {$site->url} from the route file, there is only 1 route listed:
But I guess that would break the generating of Social Images for the 'dutch' / second site, right? So, I'm guessing this isn't a good solution after all. Any idea on how to support the full, absolute url's? I'm running a multisite with different domains for language. Any advice on a better/different setup is welcome as well. |
Beta Was this translation helpful? Give feedback.
-
Hopefully I have some time to have a look at it tomorrow. First thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Thanks guys, I figured I'd better let you know not to waste any time :) I did a few hours of digging and testing just to make sure it would work in all combinations of configurations. The updated solution I found seems to be working good, solving the full absolute path problem, while still supporting the relative urls.
It generates the Social Images for both sites, with the correct content. Either working with full absolute urls or relative urls. The only issue I'm running into is that it breaks when using a full absolute 'sub-folder' domain ( To be clear, with 'breaking' I mean the '/social-images/{id}' page is loading, but the site is incorrectly set to 'default' and for that reason the content is not found. If you guys have any ideas on a fix for this, that would be great. Or, maybe those 'best practises' in the docs might just be not so 'best' after all? |
Beta Was this translation helpful? Give feedback.
-
Sorry, maybe I wasn’t clear.. I hardcoded my fix on the server, the one I
proposed lastly.
Just wanted to let you know this was successful.
So it’s not fixed, not until I can PR this and it gets merged :)
|
Beta Was this translation helpful? Give feedback.
-
Is implemented by #23 |
Beta Was this translation helpful? Give feedback.
-
Thanks for all your work guys. Love it. Have a great weekend. |
Beta Was this translation helpful? Give feedback.
-
Hi Rob,
Today I encountered a problem with the /social-images/{id} route returning a 404 error page. I managed to find the issue and figure out a fix.
I've configured my multisite url's per 'best practise' as stated here: https://statamic.dev/multi-site#url
So, using the fully qualified, absolute URL.
The route generated for the /social-images now includes that full url in the route:list. That's what causes the 404.
For me, it was fixed by removing the $site->url() in the web.php (line 28).
Route::statamic("{$site->url()}/social-images/{id}", 'statamic-peak-seo::social_images', [ 'layout' => null, ]);
to
Route::statamic("/social-images/{id}", 'statamic-peak-seo::social_images', [ 'layout' => null, ]);
Not sure why the site url was included there? I could just revert my multisite url to '/', but then we would be missing out on best practices ;-)
Curious to hear your point of view. If you agree I could PR the fix as well.
Greets, Sander
Beta Was this translation helpful? Give feedback.
All reactions