I have an existing website where I am gradually replacing the html/css interfaces with Vue technology. So now I have pages with two logics
Pages completely in vue
Pages with html/css parts and vue parts.
Currently I am using Vue (without Nuxt) with success to do this migration. In my wordpress theme I load vue scripts as follows
wp_register_script('vue-app', $directory_uri . '/js/app.js', array(), $version, true);
wp_enqueue_script('vue-app');
In order to improve my project I am switching to Nuxt. But I can't keep the same logic of integration. Nuxt does not create a unique app.js. Nuxt is generating a whole bunch of files and I cannot load them synchronously. Neither in build nor in dev (hot-module-replacement).
I don't know how to keep my logic 1 and 2 with Nuxt. Do you have any solutions ?
If you want to use Nuxt to it's full potential and keep Wordpress, you need to use Wordpress as a headless CMS. Meaning that you may use Full static and generate all of your pages during build time by reaching to your Wordpress app.
I guess that your current Wordpress + Vue flow is lacking SEO hence why you're trying to reach upon Nuxt. But to my knowledge, you will not be able to just plug it like that with your wp_register_script.
Or maybe try to mount it for every one of your routes .../about, .../our-team etc... Not a wordpress expert tho.
Related
I'm building a WordPress headless theme that is using vue 3 under the hood.
I'm able to load vue inside a page template, and I've fixed a problem I had with routing when a page were refreshed.
Now I'm facing the i18n internalization problem, I need to have the site translated into different languages, is there a way to do this in an headless theme?
If it was a traditional WP theme there are a lot of plugin that are doing this, but how I can manage this aspect in my vue app by using wp as backend?
I want to make a website using Next.js but I want to use WordPress for marketing pages. Let's say I want to use WordPress for a path example.com/sales and Next.js for others. I thought it could be done with load balancing but I'm new to this topic and not sure what I should do. How do I do that?
I think what you are looking for is called incremental adoption. Basically if a certain path is not part of your nextjs app, the traffic falls back to the specified url.
here are the official docs
I have a large Nuxt.js project with many different components. Now I want to reuse these components in a new project which uses WordPress. So for example I want to be able to display a certain component on a WordPress page or post.
My first thought was to only use Vue.js without Nuxt but then I would not be able to use the Nuxt components without having to remove Nuxt-specific code. I know that there is also a way to use Nuxt programmatically as a middleware but I can't figure out how to do this with WordPress.
Can someone guide me into the right direction?
I have been exploring using Vue for wordpress frontend, and I came across so many different technologies, like Nuxt.js, Gridsome, VuePress, and they help to create sites into SPA, SSR, or static sites. I really like these ideas, because I want to move into modern frontends instead of using the WordPress default. So I am looking into headless WordPress.
After some research, I think I kind of like Gridsome with Wordpress, as Gridsome helps to build static site by compiling content from CMS and templates at build time.
So I have a very newbie question, CMS like wordpress gets updated everyday by users, to update pages, add new posts etc, does that mean you need to build the site every time people add some content to the CMS?
I'm going to build a sort of internal portal, with WordPress and I want to try out Vue, so with all these technologies out there, I am lost at what framework best suit my project with dynamic content.
Any suggestions or insights? Thanks.
So I have a very newbie question, CMS like wordpress gets updated everyday by > users, to update pages, add new posts etc, does that mean you need to build the > site every time people add some content to the CMS?
Yes that's the concept of a statically generated site.
Still it's a choice of how you design your application.
Normally when a new post is created there can be an event / webhook triggering a build job which would automatically build and deploy the page with the latest post.
Still you can have in your deployed application client side Vue components which call the API directly to retrieve data and display it. For example for the comments it could make sense to do this.
Netlify is a good example which has the whole static site generation eased up with a nice CI / CD which can be triggered automatically as soon as your site. They also have a CMS which works on top of markdown files. As soon as a changed / new markdown file is commited to the repository it triggers a build to deploy the latest version of the page.
I hope this helps.
Thanks and best regards,
ewatch
I am new to web development and and would like advice about what is the usual best practices to achieve what I am trying to do.
I am in charge of writing a frontend app using Vue. This frontend will require a login to access the app. The app will be hosted on Amazon.
However we are also wanting to build an eCommerce site in Wordpress or equivalent that sits on the root of the website, (eg www.mywebsite.com) with the app accessible through a "sign in" button. If the user presses the sign in button we want the location bar location to not change from the website they are on (www.mywebsite.com), even though the Wordpress site and Vue frontend may be stored on different locations/domains.
If the site is made in Wordpress, we can get another developer to do that webpage for us, while I work on the frontend. However we want the experience to be relatively seamless between connecting to the wordpress root site, clicking on the sign in button and being taken to the Vue frontend.
Is this possible? Do both sites have to be hosted on the same server for it to work (eg an Amazon EC2 server which hosts two webpages, the wordpress one and the vue one)?
Or can the wordpress put a link to the Vue frontend which doesn't change the web location to the user?
Or (worst case scenario) do we need to make both webpages in Vue as one Vue application, some pages requiring login to access and others not?
Thanks kindly for any assistance.
So in order to use Vue and WordPress together, you can either write 2 separate applications. One for the Frontend and one for the Backend, which is perfectly fine or you can simply write a WordPress Application with a Vue Theme.
This is how this could look like:
WordPress Backend
You can use a normal WordPress backend, where you can build the architecture you want to. In addition, you need to set up the REST-API Wordpress provides. So this also means, just use plugins which support it. Otherwise, you would need to write custom endpoints. For example, Woocommerce would be a good e-commerce plugin, since it supports the API.
Learn more about it here: https://v2.wp-api.org/
Of course, you can host your WordPress installation on Amazon. Here is a good guide for that: https://aws.amazon.com/de/getting-started/tutorials/launch-a-wordpress-website/
Notice: The REST-API is available in core since 4.7. If you are using an older version you would need to install a plugin.
WordPress Frontend
In order to create your Frontend, I'd recommend you to make a custom theme. Since you are just serving static files this can be done pretty easy. But still, you don't need to reinvent the wheel.
There's a really good starter theme out there: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
It comes with all the stuff you need to get started and since it is just a theme, you can simply set up a usual WordPress hosting without handling Domains of multiple applications.
In order to get the data from the Backend, you would simply make calls to the REST-API. Here's an example: https://github.com/EvanAgee/vuejs-wordpress-theme-starter/blob/master/src/api/index.js