Drupal 8 as a Static Site: Problems Identified

Submitted by nigel on Thursday 8th November 2018
Search doesn't work
Search

It's churlish to say that search doesn't work. It's like jumping on the wrong bus and then complaining it didn't go past your house. Of course search doesn't work - it needs to bootstrap Drupal once the search form is submitted. But we do need to find a solution to that - and I will be discussing Elasticsearch in a later chapter. 

Drupal Planet feed rendered as HTML
Planet View
html
This is another blindingly obvious problem and something that should be expected. I have a Drupal Planet RSS feed which is generated by a View (see first screenshot) and outputs XML to the route /planet/feed. Tome will render all routes with no extension using the following rule: create a directory with the route name, and then create an index.html file with the content in that directory. This can be seen below:
$ pwd
/var/www/html/meedjum/static/html/planet/feed
vagrant@nigel-dev-box:/var/www/html/meedjum/static/html/planet/feed$ ls -las
total 8
0 drwxrwxr-x 3 501 dialout   96 Nov  8 10:38 .
0 drwxrwxr-x 5 501 dialout  160 Nov  7 09:14 ..
8 -rw-rw-r-- 1 501 dialout 6817 Nov  7 09:00 index.html
The second screenshot shows what happens when an html file of RSS format XML is presented to a browser. It is totally mangled. The solution involves web server configuration as well as a few tweaks at the Drupal end, and will be explained in a separate blog since it also part-involves the problem identified below.
Term feeds are not created
terms

I am extensively using the Views term landing pages in my blog, and they always have an RSS subscribe button at the bottom of the page which will link to the path /taxonomy/term/%/feed. Tome doesn't have the capability to generate these routes since they are using wildcards. This is bad news from my perspective since I could have many subscribers to these feeds although of course there is no easy way of determining this.

Regardless, there is a solution to this which involves custom code and the development of an event subscriber. Tome itself uses the same concept to garner all the routes to render - RoutePathSubscriber.php. A custom module would need to be created along the same lines, only in my instance I would need to provide all the routes that use /taxonomy/term/%/feed where % will be the term id.

Once I've done that - in a forthcoming chapter  - I will still be faced with the same problem I identified above. I will now have for instance a route /taxonomy/term/71/feed where 71 would be the term id of the term 'Drupal'. So Tome would create a directory structure /taxonomy/term/71/feed and populate it with an index.html file. Thus the solution I find for my previous problem will have to be extended for these routes too.